我正在尝试运行下面给出的代码,但不幸的是我收到以下错误-“MNIST 对象没有属性数据”。错误是因为“mnist_train_set.data.view(-1, 1, 28, 28).float()”这一行。有人可以阐明如何解决这个问题吗?谢谢。
import torch
from torchvision import datasets
...
mnist_train_set = datasets.MNIST(data_dir + '/mnist/', train = True, download = True)
mnist_test_set = datasets.MNIST(data_dir + '/mnist/', train = False, download = True)
train_input = mnist_train_set.data.view(-1, 1, 28, 28).float()
train_target = mnist_train_set.targets
test_input = mnist_test_set.data.view(-1, 1, 28, 28).float()
test_target = mnist_test_set.targets