question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue
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'

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
rambo-codercommented, May 6, 2021
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

0reactions
zenghuhcommented, 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

'CIFAR10' object has no attribute 'train_labels' #3 - GitHub
In recent versions, the variable for the labels for the training samples in torchvision.datasets.CIFAR10 is not called "train_labels" anymore, ...
Read more >
cifar-10 - Kaggle
Explore and run machine learning code with Kaggle Notebooks | Using data from CIFAR-10 - Object Recognition in Images.
Read more >
Is torchvision.datasets.cifar.CIFAR10 a list or not?
Slicing isnt supported by CIFAR10, which is why you are getting that error. If you want the first 10 you will have to...
Read more >
Source code for torchvision.datasets.cifar - chsasank.com
Args: root (string): Root directory of dataset where directory ``cifar-10-batches-py`` exists. train (bool, optional): If True, creates dataset from ...
Read more >
Final Project: Reproduce One Result of ”Understanding Deep ...
Resnet, and train that on random labels on the CIFAR10 dataset. ... AttributeError: 'CIFAR10RandomLabels' object has no attribute 'train_labels'.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found