problem in implementing FedAvg algorithm in TF

29 views Asked by At

I am implementing FL using TF in google colab ( not using TFF), I am using Bot-IoT datasets and I divide the data into 10 clients such that each client take all types of classes so it can train on all classes.

The problem that I face is in the aggregation of the received model weights from each client to get the global accuracy and recall which is 0% in my code.

here is the aggregation function:

def federated_averaging(client_weights): new_weights = [] # Number of layers in the model

# Sum the weights
for weights_list_tuple in zip(*client_weights):  # Iterate over each layer
    layer_mean = np.mean(np.array([np.array(weights) for weights in weights_list_tuple]), axis=0)
    
    new_weights.append(layer_mean)

return new_weights

my code is to collect the model weights in each round and then to average the weights to get the average weight that used to calculate the global accuracy.

0

There are 0 answers