Skip to content

docs: Keras 3 evaluate() and compiled metrics clarification #21506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions keras/src/trainers/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,8 +793,16 @@ def evaluate(
Returns:
Scalar test loss (if the model has a single output and no metrics)
or list of scalars (if the model has multiple outputs
and/or metrics). The attribute `model.metrics_names` will give you
the display labels for the scalar outputs.
and/or metrics).

Note: When using compiled metrics, `evaluate()` may return multiple
submetric values, while `model.metrics_names` often lists only
top-level names (e.g., 'loss', 'compile_metrics'), leading to a
length mismatch. The order of the `evaluate()` output corresponds
to the order of metrics specified during `model.compile()`. You can
use this order to map the evaluate() results to the intended
metric. `model.metrics_names` itself will still return only the
top-level names.
"""
raise NotImplementedError

Expand Down