The Fashion MNIST dataset is implemented pretty weirdly in Pytorch. I want to do something like:
X, y = FashionMNIST
But in reality, it's a little more complicated. This is what I have:
from torchvision.datasets import FashionMNIST
train = FashionMNIST(root='.', download=True, train=True)
print(train)
The output:
Dataset FashionMNIST
Number of datapoints: 60000
Root location: c:/users/nicolas/documents/data/fashionmnist
Split: Train
What one observation looks like:
print(train[0])
(<PIL.Image.Image image mode=L size=28x28 at 0x20868074780>, 9)
I could only do it for one observation.
X, y = train[0]
So how do I separate the input and targets?
FashionMNIST
object has data
and targets
attributes.
You can simply write
X, y = train.data, train.targets
and then you can see the shapes
X.shape, y.shape
(torch.Size([60000, 28, 28]), torch.Size([60000]))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.