AshwinRJ / Federated-Learning-PyTorch

Implementation of Communication-Efficient Learning of Deep Networks from Decentralized Data
MIT License
1.29k stars 451 forks source link

Regarding attribute errors during the federated learning both in equal and unequal cases #33

Open parjanay opened 2 years ago

parjanay commented 2 years ago

While running the code, the following attribute errors were coming. Can anyone tell the reasons for such errors?? For equal case:

Traceback (most recent call last):
  File "src/federated_main.py", line 36, in <module>
    train_dataset, test_dataset, user_groups = get_dataset(args)
  File "C:\Users\sharm\Downloads\Federated-Learning-PyTorch-master\src\utils.py", line 41, in get_dataset
    user_groups = cifar_noniid(train_dataset, args.num_users)
  File "C:\Users\sharm\Downloads\Federated-Learning-PyTorch-master\src\sampling.py", line 173, in cifar_noniid
    labels = np.array(dataset.train_labels)
  File "C:\Users\sharm\.conda\envs\newEnv\lib\site-packages\torch\utils\data\dataset.py", line 83, in __getattr__
    raise AttributeError
AttributeError

For Unequal case:

Traceback (most recent call last):
  File "src/federated_main.py", line 36, in <module>
    train_dataset, test_dataset, user_groups = get_dataset(args)
  File "C:\Users\sharm\Downloads\Federated-Learning-PyTorch-master\src\utils.py", line 38, in get_dataset
    raise NotImplementedError()
NotImplementedError
wak-m commented 2 years ago

The CIFAR-10 dataset does not have an attribute train_labels. NotImplementedError is coded to be raised for parts that are not yet implemented.

wmabebe commented 2 years ago

The latest CIFAR-10 dataset calls it's labels "targets". So replace line 173 to. labels = np.array(dataset.targets)