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 ?
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 ?
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)