简体   繁体   English

如何在 tensorflow federated 中保存权重

[英]How to save weights in tensorflow federated

I want to save weights only when loss is getting lower and reuse them for evaluation.我只想在损失越来越低时保存权重并将它们重用于评估。

lowest_loss = Inf

    if loss[round] < lowest_loss:
        lowest_loss = loss[round]

        model_weights = transfer_learning_iterative_process.get_model_weights(state)



eval_metric = federated_eval(model_weights, [fed_valid_data])

where:在哪里:

  federated_eval = tff.learning.build_federated_evaluation(model_fn)

Is there a possible way to save server weights in hdf5 format or as a checkpoint and reuse it?有没有办法以 hdf5 格式保存服务器权重或作为检查点并重用它?

Yes, this can be done with helpers in TFF.是的,这可以通过 TFF 中的助手来完成。 Generally, this kind of functionality is implemented by tff.program.ProgramStateManagers .通常,这种功能由tff.program.ProgramStateManagers实现。 An implementation which saves to a filesystem can be found here , and example usages can be found in the implementation of tff.simulation.run_training_process .保存到文件系统的实现可以在这里找到,示例用法可以在tff.simulation.run_training_process的实现中找到。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM