Federated-Learning-PyTorch icon indicating copy to clipboard operation
Federated-Learning-PyTorch copied to clipboard

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

Open parjanay opened this issue 4 years ago • 2 comments

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

parjanay avatar Feb 08 '22 06:02 parjanay

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

wak-m avatar Feb 17 '22 04:02 wak-m

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

wmabebe avatar May 28 '22 07:05 wmabebe