Skip to content

Commit

Permalink
fix: correct metrics argument format in model.compile
Browse files Browse the repository at this point in the history
Resolved a ValueError caused by passing a single metric object to the `metrics` argument of `model.compile`. Updated it to a list containing `tf.keras.metrics.BinaryAccuracy` to comply with Keras requirements.

Error message:
ValueError: Expected `metrics` argument to be a list, tuple, or dict.
  • Loading branch information
yclian0528 committed Dec 16, 2024
1 parent 5a84fbf commit 190497c
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def _get_optimized_divergence_estimation_model(
self._training_options.optimizer_learning_rate
),
loss=tf.keras.losses.BinaryCrossentropy(from_logits=True),
metrics=tf.keras.metrics.BinaryAccuracy(threshold=0.0),
metrics=[tf.keras.metrics.BinaryAccuracy(threshold=0.0)],
)
features, labels = self._generate_inputs_to_model(
samples_first_distribution,
Expand Down

0 comments on commit 190497c

Please sign in to comment.