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

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

Open MrLinNing opened this issue 4 years ago • 5 comments

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'

MrLinNing avatar Apr 03 '20 13:04 MrLinNing

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

Murphyzzz avatar Apr 13 '20 03:04 Murphyzzz

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 avatar Apr 19 '20 07:04 tanjuntao

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?

tanjuntao avatar Apr 19 '20 07:04 tanjuntao

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.

zenghuh avatar Jul 28 '20 08:07 zenghuh

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

rambo-coder avatar May 06 '21 03:05 rambo-coder