如何将自己的数据集更改为MNIST数据集格式?

问题描述 投票:0回答:1
data_transform_test = transforms.Compose([transforms.ToTensor(),
                                          transforms.Grayscale(num_output_channels=1),
                                          transforms.Resize((28, 28)),
                                          transforms.Normalize((0.5,), (0.5,))
                                          ])

这是我尝试实现基于 MNIST 数据集的模型的方法。我无法改变整个模型架构,因为这对我来说负担太大。但我的代码给了我这个错误。你们还有什么建议吗?需要修改吗?

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-59-ce644b7b7998> in <module>()
      1 # training for 3 epochs
      2 n_epochs = 3
----> 3 losses = train(capsule_net, criterion, optimizer, n_epochs=n_epochs)

<ipython-input-58-54eb5db28cd7> in train(capsule_net, criterion, optimizer, n_epochs, print_every)
     26 
     27             # reshape and get target class
---> 28             target = torch.eye(10).index_select(dim=0, index=target)
     29 
     30             if TRAIN_ON_GPU:

IndexError: index out of range in self
python neural-network pytorch conv-neural-network mnist
1个回答
-1
投票

你找到解决办法了吗?

我正在尝试做同样的事情,但到目前为止已经碰壁了。

© www.soinside.com 2019 - 2024. All rights reserved.