I’m using Pytorch version 1.1.0 installed with fast.ai library and trying to get to know more about the framework about how it works.
I’ve been going through the blitz tutorial and on the one with training a classifier with CIFAR10 dataset, I’m stuck at a certain point where we use the Data Loader on the training sample :
# get some random training images
dataiter = iter(trainloader)
images, labels = dataiter.next()
When I want to run this code, it gives me the following error :
TypeError: object() takes no parameters
I don’t understand why it does this error, I’ve tried to uninstall and re-install yet it still keep doing the same error
Welcome to the PyTorch community!
It’s a bit hard to tell the context without seeing the rest of your code. Also, I’m not sure what kind of wrapping fast.ai has done, but this could be coming from their library.
The typical way to interact with datasets in PyTorch looks like something like this:
>>> mnist = MNIST(r"some root directory", download=True, train=True, transform=ToTensor())
>>> data = DataLoader(mnist)
>>> for num, (input, label) in enumerate(data):
data in this case, an instance of the
DataLoader class is itself an iterator. You can use normal python looping constructs on this. You shouldn’t have to call
Thank you for your answer!
The code comes from the official PyTorch training a classifier tutorial here
EDIT : Just found the mistake…
In the code below, I’ve not put “()” after the function
transform = transforms.Compose([transforms.ToTensor,
Which led to the TypeError. But I’ve got confused as the error pointed at the lines I’ve mentioned before on my first post.
Sorry for the inconvenience and thank you for your answer!