问题
So im trying to learn pytorch and i got this code from a tutorial and its just there to import a mnist dataset but it outputs "TypeError: 'module' object is not callable" In the tutorial "dataloader" was written as "Dataloader" but when i run it like that it outputs "AttributeError: module 'torch.utils.data' has no attribute 'Dataloader'"
The data downloaded inside a file mnist but i dont know if it is complete
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optom
from torchvision import datasets, transforms
from torch.autograd import Variable
kwargs={}
train=torch.utils.data.dataloader(datasets.MNIST("mnist",train=True,download=True,transform=transforms.Compose([transforms.ToTensor(),transforms.Normalize((0.1307),(0.3081,) )] ) ),batch_size=64, shuffle=True, **kwargs)
回答1:
It's neither dataloader nor Dataloader but DataLoader :)
Side-note: if you're new to PyTorch, consider using the newest version 1.0. torch.autograd.Variable is deprecated as of PyTorch 0.4.1 (I believe) so you're either using an older version of PyTorch or an outdated tutorial.
来源:https://stackoverflow.com/questions/53693999/torch-utils-data-dataloader-outputs-typeerror-module-object-is-not-callable