简体   繁体   English

如何将输入和目标与 Pytorch Fashion MNIST 分开?

[英]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对象具有datatargets属性。

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.

相关问题 如何在 pytorch 中为 Fashion_MNIST 使用 MSELoss function? - How to use MSELoss function for Fashion_MNIST in pytorch? 我如何将 KNN 训练到 Fashion MNIST 上? - How can I train KNN onto Fashion MNIST? 如何将用户名输入与游戏输入分开? - How do I separate the username input from the game input? 怎么把Fashion MNIST转换成Dataset class? - How to convert Fashion MNIST to Dataset class? 如何在 Tensorflow Fedarated 中加载 Fashion MNIST 数据集? - How to load Fashion MNIST dataset in Tensorflow Fedarated? 如何将 MNIST 图像加载到 Pytorch DataLoader 中? - How do you load MNIST images into Pytorch DataLoader? 如何在 PyTorch 中将 autograd 用于独立于反向传播的单独函数? - How do I use autograd for a separate function independent of backpropagate in PyTorch? 如何在python中调整图像的大小以降低MNIST时尚数据等灰度低分辨率? - How can I resize an image in python to gray scale low resolution like MNIST fashion data? 如何为 MNIST 时尚构建 CNN model 并使用来自 web 的另一组图像对其进行测试? - How to build a CNN model for MNIST fashion and test it with a another set of image from web? 如何将数字与输入分开以添加数字? - How do I separate the numbers from an input in order to add them?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM