WHDY / FedAvg

Implement FedAvg algorithm based on Tensorflow
234 stars 53 forks source link

TypeError: 'NoneType' object is not subscriptable #2

Open pangying1104 opened 3 years ago

pangying1104 commented 3 years ago

Hi,

I created a virtual environment as your suggestion. But I got the following error:

Extracting ./data/MNIST\train-images-idx3-ubyte.gz
Extracting ./data/MNIST\train-labels-idx1-ubyte.gz
Extracting ./data/MNIST\t10k-images-idx3-ubyte.gz
Extracting ./data/MNIST\t10k-labels-idx1-ubyte.gz
communicate round 0
  0%|          | 0/10 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "E:/OneDrive - University of Otago/research/FedAvg/server.py", line 87, in <module>
    local_vars = myClients.ClientUpdate(client, global_vars)
  File "E:\OneDrive - University of Otago\research\FedAvg\clients.py", line 112, in ClientUpdate
    train_data, train_label = self.clientsSet[client].next_batch(self.B)
  File "E:\OneDrive - University of Otago\research\FedAvg\clients.py", line 38, in next_batch
    return self.train_dataset[start:end], self.train_label[start:end]
TypeError: 'NoneType' object is not subscriptable

Do you know the reason? Thank you very much for your great help.

pangying1104 commented 3 years ago

I found out the reason. There was a little bug. The code in line 20 of Clients.py "self.train_labellabel = self.label" should be "self.train_label = self.label"