0
votes

I'm new to Pytorch and torchvision. I followed a tutorial that is roughly a year old where he tried to download mnist via python and torchvision.

This is how:

import torch
from torchvision import datasets, transforms

kwargs = {'num_workers': 1, 'pin_memory': True}
train = torch.utils.data.DataLoader(
    datasets.MNIST('data', train=True, download=True,
                   transform=transforms.Compose([transforms.ToTensor(),
                   transforms.Normalize((0.1307,), (0.3081,))])),
    batch_size=64, shuffle=True, **kwargs)
test = torch.utils.data.DataLoader(
    datasets.MNIST('data', train=False,
                   transform=transforms.Compose([transforms.ToTensor(),
                   transforms.Normalize((0.1307,), (0.3081,))])),
    batch_size=64, shuffle=True, **kwargs)

Now my problem is that I get this error:

Traceback (most recent call last):

Downloading http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz to data\MNIST\raw\train-images-idx3-ubyte.gz

File "C:/Users/Nico/PycharmProjects/PyTorch/mnist.py", line 13, in transforms.Normalize((0.1307,), (0.3081,))])),

File "C:\Users\Nico\AppData\Local\Programs\Python\Python37\lib\site-packages\torchvision\datasets\mnist.py", line 68, in init self.download()

File "C:\Users\Nico\AppData\Local\Programs\Python\Python37\lib\site-packages\torchvision\datasets\mnist.py", line 143, in download download_url(url, root=self.raw_folder, filename=filename, md5=None)

File "C:\Users\Nico\AppData\Local\Programs\Python\Python37\lib\site-packages\torchvision\datasets\utils.py", line 73, in download_url reporthook=gen_bar_updater(tqdm())

TypeError: init() missing 1 required positional argument: 'total'

Do any of you guys know what I have to change, or how I can download/use them? As I said earlier I'm new to it and I don't have any clue.

I hope you guys can help me, thanks in advance.

Greetings Nico aka. Myridor

1
Works fine on PyTorch 1.0.0.kHarshit
I got PyTorch 1.0.1, gonna try it with 1.0.0Myridor
Which version of torchvision you got? I got 0.2.2.post2Myridor
torchvision is '0.2.1'kHarshit

1 Answers

0
votes

So the problem wasn't the code or the naming or anything.

It was the torchvision version. I had 0.2.2.post2 and it worked with 0.2.1!