提交 8d3641ed 编辑于 作者: A. Unique TensorFlower's avatar A. Unique TensorFlower 提交者: tensorflow-copybara
浏览文件

Fix error message to call correct method.

In case of error during initialization , code throws error while formatting error message here. That error overrides actual init error. This fix will address that.
Plus added some more comments as implementation guideline.

PiperOrigin-RevId: 344105882
上级 822e5df4
......@@ -203,6 +203,10 @@ def federated_aggregate_keras_metric(
# used. This is somewhat limiting, but the pattern to use default
# arguments and export the values in `get_config()` (see
# `tf.keras.metrics.TopKCategoricalAccuracy`) works well.
#
# If type(metric) is subclass of another tf.keras.metric arguments passed
# to __init__ must include arguments expected by the superclass and
# specified in superclass get_config().
keras_metric = None
try:
# This is some trickery to reconstruct a metric object in the current
......@@ -215,7 +219,7 @@ def federated_aggregate_keras_metric(
'Caught exception trying to call `{t}.from_config()` with '
'config {c}. Confirm that {t}.__init__() has an argument for '
'each member of the config.\nException: {e}'.format(
t=type(metric), c=metric.config(), e=e))
t=type(metric), c=metric.get_config(), e=e))
assignments = []
for v, a in zip(keras_metric.variables, values):
......
Supports Markdown
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册