UserWarning: test_data has been renamed datawarnings.warn("test_data has been renamed data")
UserWarning: test_labels has been renamed targets warnings.warn("test_labels has been renamed targets")
后来发现是载入数据集的属性应该是data和target,而不是之前写的test_data,test_labels,改完之后即可。
test_x = torch.unsqueeze(test_data.data, dim=1).type(torch.FloatTensor)[:2000]/255. # shape from (2000, 28, 28) to (2000, 1, 28, 28), value in range(0,1) test_y = test_data.targets[:2000] 12