[英]How do I separate the input and targets from Pytorch Fashion MNIST?
The Fashion MNIST dataset is implemented pretty weirdly in Pytorch. Fashion MNIST 数据集在 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. FashionMNIST
对象具有data
和targets
属性。
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]))
(torch.Size([60000, 28, 28]), torch.Size([60000]))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.