Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
MrLinNing opened this issue Apr 3, 2020 · 5 comments
Open

Comments

@MrLinNing
Copy link

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
Copy link

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
Copy link

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
Copy link

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
Copy link

zenghuh commented Jul 28, 2020

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants