1

如何轻松保存 Tensorflow 联合模型?(状态)

几个月前,我在导入ServerStateFileCheckPointManager后使用了这个解决方案,它起作用了:

# Create the checkpoint Manager
ckpt_manager = FileCheckpointManager(root_dir=checkpoint_dir)
# Save checkpoint for round N
ckpt_manager.save_checkpoint(ServerState.from_tff_result(state), round_num=NUM_ROUNDS)

但是现在这个解决方案不再有效,因为ServerState不再包含from_tff_resultmethotd。

AttributeError: type object 'ServerState' has no attribute 'from_tff_result'

还使用包含方法的旧版本的 ServerState 我得到:

TypeError: Expected tensorflow_federated.python.common_libs.structure.Struct, found tensorflow_federated.python.learning.model_utils.ModelWeights.

如何轻松保存我的联合模型?

4

1 回答 1

0

最近进行更改以防止Struct(以前AnonymousTuple)返回给用户之后,应该不再需要像ServerState.from_tff_result(state);这样的方法。state应该 已经ServerState.

TLDR:如果您将示例更新为简单地阅读:

# Create the checkpoint Manager
ckpt_manager = FileCheckpointManager(root_dir=checkpoint_dir)
# Save checkpoint for round N
ckpt_manager.save_checkpoint(state, round_num=NUM_ROUNDS)

它应该可以工作。

于 2020-10-01T05:09:01.917 回答