torch.utils.data.dataloader outputs TypeError: 'module' object is not callable

一个人想着一个人 提交于 2020-12-13 02:55:19

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!