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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistency between torchvision.datasets.cifar.CIFAR10.data return and torchvision.datasets.cifar.CIFAR10.__getitem__() #126645

Closed
CircuitsOfAIM opened this issue May 19, 2024 · 1 comment

Comments

@CircuitsOfAIM
Copy link

CircuitsOfAIM commented May 19, 2024

馃悰 Describe the bug

It is intuitive to access training and/or target data in torchvision.datasets.cifar.CIFAR10 class with torchvision.datasets.cifar.CIFAR10.data or torchvision.datasets.cifar.CIFAR10.target.

ISSUE when transform applied these values are different from values acquired using indices i.e. train_dataset[0] done by__getitem__()

import torch
import torchvision.datasets as datasets
import torchvision.transforms as transforms


train_dataset =  datasets.CIFAR10(root='./data', train=True, download=True, transform=train_transforms)
train_transforms = transforms.Compose([
    transforms.RandomHorizontalFlip(p=0.5),
    transforms.ToTensor(),
    transforms.Normalize((0.4914, 0.4822, 0.4465), (0.2023, 0.1994, 0.2010))
])
with_data=train_dataset.data[0,0,0,:]
with_idx,_=train_dataset[0][:,0,0].numpy()

print(with_data == with_idx)

Versions

PyTorch version: 2.3.0+cpu
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

Python version: 3.11.5 |
Is CUDA available: False
Is XNNPACK available: True

[pip3] numpy==1.26.2
[pip3] torch==2.3.0
[pip3] torchsummary==1.5.1
[pip3] torchvision==0.18.0
[conda] mkl 2021.4.0 pypi_0 pypi
[conda] numpy 1.26.2 pypi_0 pypi
[conda] torch 2.3.0 pypi_0 pypi
[conda] torchsummary 1.5.1 pypi_0 pypi
[conda] torchvision 0.18.0 pypi_0 pypi

Tasks

No tasks being tracked yet.
@CircuitsOfAIM CircuitsOfAIM changed the title Inconsistency between CIFAR10.data and "img" returned from CIFAR.__getitem__() Inconsistency between torchvision.datasets.cifar.CIFAR10.data and "img" returned from torchvision.datasets.cifar.CIFAR10.__getitem__() May 22, 2024
@CircuitsOfAIM CircuitsOfAIM changed the title Inconsistency between torchvision.datasets.cifar.CIFAR10.data and "img" returned from torchvision.datasets.cifar.CIFAR10.__getitem__() Inconsistency between torchvision.datasets.cifar.CIFAR10.data return and torchvision.datasets.cifar.CIFAR10.__getitem__() May 22, 2024
@jbschlosser
Copy link
Contributor

Hey @CircuitsOfAIM, this seems like it should be in https://github.com/pytorch/vision. Do you mind opening an issue there? Thanks!

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

2 participants