Search code examples
pythontensorflowtensorflow-federatedfederated-learning

How to change the update that the client send to the server Tensorflow Federated


I'm trying to understand how Tensorflow Federated Works, using the simple_fedavg as example.

I still don't understand how to change what the client send to the server, for example.

I don't want to send all the weights of the update, i want to send a list formed like this:

  test[index] = test_stc.stc_compression(test[index], sparsification_rate)

Where test_stc.stc_compression(test[index], sparsification_rate) return 5 values: negatives, positives, average, original_shape, new_shape, then i would like to access those information on the server side before running the round_model_delta = tff.federated_mean(client_outputs.weights_delta, weight=weight_denom) for creating the weights that i will use for the tff.federated_mean.

So, basically, i would like to change client_update to send a list that i have created instead of all the weights and then, on the server create a custom list of weights using the information that the client sent. Only after the creation of the new custom list of weight i would like the server to update the model.

I actually tried to change the return ClientOutput(test, client_weight, loss_sum / client_weight) of the client_update, but then i don't know how to access the test variable on the server and in which procedure/function i would need to do it.

I hope that i made myself clear enough since my main language is not english.


Solution

  • See tff.federated_aggregate operator which exposes the control you probably need (I am not sure I follow what that is), including what computation should be done on each client value at server before being added to an aggregation accumulator.

    You can think of the mentioned tff.federated_mean as a special case of this general operator.