【问题标题】:What state = iterative_process.initialize() dow in Federated learning联邦学习中的什么状态 = iterative_process.initialize()
【发布时间】:2021-03-11 09:18:01
【问题描述】:

我是联邦学习的新手,我尝试实现 FL 的代码进行图像分类,但我无法理解这一行:state = iterative_process.initialize() ,Weights 从哪里影响到服务器?

【问题讨论】:

  • 您能澄清一下这个问题吗?我不太明白。同时,有些混淆可能是因为 TFF 是一个函数式编程环境。可能值得阅读tensorflow.org/federated/federated_learning#modeling_state 以及指南中的更多详细信息。
  • 这就是我想说的:初始状态从何而来。这意味着 .Iterative_process 如何生成初始权重

标签: tensorflow-federated federated-learning


【解决方案1】:

如何生成初始权重取决于您所掌握的tff.templates.IterativeProcess 的特定实现。使用tff.learning.build_federated_averaging_process,这些权重将与those returned upon invocation of the model_fn 相同。

但是,如果您愿意,您可以控制这些语义。

例如,可以从磁盘加载权重:

@tff.tf_computation
def get_weights_from_disk():
  # load weights from wherever
  return loaded_weights

@tff.federated_computation
def server_init():
  # There may be state other than weights that needs to get returned from here,
  # as in the implementation of build_federated_averaging_process.
  return tff.federated_eval(get_weights_from_disk, tff.SERVER), ...

然后您可以像这样创建一个新的迭代过程,只要我们上面编写的函数的类型签名与我们试图替换的迭代过程中的初始化函数的类型匹配:

old_iterproc = tff.learning.build_federated_averaging_process(...)
new_iterproc = tff.templates.IterativeProcess(intialize_fn=server_init,
  next_fn=old_iterproc.next)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-06-29
    • 2021-07-08
    相关资源
    最近更新 更多