AttributeError: 'collections.OrderedDict' object has no attribute 'train'

AttributeError: 'collections.OrderedDict' object has no attribute 'train'

with summary_writer.as_default():
  for round_num in range(1, NUM_ROUNDS):
    state, metrics = iterative_process.next(state, federated_train_data)
    # for name, value in metrics.train._asdict().items():
    tf.summary.scalar('metrics', metrics.train._asdict().itrems(), step=round_num)

我只是被困在这里。我收到如下错误消息: A​​ttributeError: 'collections.OrderedDict' 对象没有属性 'train' 指标如下所示:

metrics=OrderedDict([('broadcast', ()), ('aggregation', ()), ('train', OrderedDict([('sparse_categorical_accuracy', 0.12695473), ('loss', 3.0522373)]))])

非常感谢任何帮助。

看起来像

metrics.train._asdict().itrems()

应该是

metrics['train'].items()