AshwinRJ / Federated-Learning-PyTorch

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

AttributeError: 'CIFAR10' object has no attribute 'train_labels' #9

Open MrLinNing opened 4 years ago

MrLinNing commented 4 years ago
Files already downloaded and verified
Traceback (most recent call last):
  File "/Federated-Learning-PyTorch/src/sampling.py", line 282, in <module>
    d = cifar_noniid(dataset_train, num)
  File "/Federated-Learning-PyTorch/src/sampling.py", line 248, in cifar_noniid
    labels = np.array(dataset.train_labels)
AttributeError: 'CIFAR10' object has no attribute 'train_labels'
Murphyzzz commented 4 years ago

my problem is "ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 50000 and the array at index 1 has size 60000 @AshwinRJ Have you solved @MrLinNing

tanjuntao commented 4 years ago
Files already downloaded and verified
Traceback (most recent call last):
  File "/Federated-Learning-PyTorch/src/sampling.py", line 282, in <module>
    d = cifar_noniid(dataset_train, num)
  File "/Federated-Learning-PyTorch/src/sampling.py", line 248, in cifar_noniid
    labels = np.array(dataset.train_labels)
AttributeError: 'CIFAR10' object has no attribute 'train_labels'

I met the same problems as you before, I tried to use dataset.targets instead and it just worked fine. So my code is:

labels = np.array(dataset.targets)
tanjuntao commented 4 years ago

my problem is "ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 50000 and the array at index 1 has size 60000 @AshwinRJ Have you solved @MrLinNing

Could you provide a more detailed error message? For example, which line is this error come from?

zenghuh commented 4 years ago

my problem is "ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 50000 and the array at index 1 has size 60000 @AshwinRJ Have you solved @MrLinNing

num_shards, num_imgs = 200, 250 200*250=50000 ,the multiplication of these need equal to 60,000.

rambo-coder commented 3 years ago
Files already downloaded and verified
Traceback (most recent call last):
  File "/Federated-Learning-PyTorch/src/sampling.py", line 282, in <module>
    d = cifar_noniid(dataset_train, num)
  File "/Federated-Learning-PyTorch/src/sampling.py", line 248, in cifar_noniid
    labels = np.array(dataset.train_labels)
AttributeError: 'CIFAR10' object has no attribute 'train_labels'

Change train_labels to targets