2

I'm new in Federated learning, I tried to implement the code of FL for image classification, but I can't understand this line : state = iterative_process.initialize() , Weights affected to the server from where ?

seni
  • 659
  • 1
  • 8
  • 20
  • Could you clarify the question, please? I don't quite understand it. In the meantime, some confusion may be from the fact that TFF is a functional programming environment. It may be worth reading https://www.tensorflow.org/federated/federated_learning#modeling_state and more details in the guide. – Jakub Konecny Mar 11 '21 at 11:50
  • That's I want to say : where the initial state comes from. meaning that how .Iterative_process generates initial weights – seni Mar 11 '21 at 11:58

1 Answers1

2

How the initial weights are generated depends on the particular implementation of the tff.templates.IterativeProcess you have your hands on. Using tff.learning.build_federated_averaging_process, these weights will be identical to those returned upon invocation of the model_fn.

However, you are in control of these semantics if you wish to be.

For example, weights can be loaded from disk:

@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), ...

You could then create a new iterative process like so, as long as the type signature of the function we wrote above matches the type of the initialize function in the iterative process we are attempting to replace:

old_iterproc = tff.learning.build_federated_averaging_process(...)
new_iterproc = tff.templates.IterativeProcess(intialize_fn=server_init,
  next_fn=old_iterproc.next)
Keith Rush
  • 1,360
  • 7
  • 6