I use following code to get the MNIST dataset:
import torchvision.datasets
MNIST_train = torchvision.datasets.MNIST('./', download=True, train=True)
This code worked times ago, but now it shows the error:
Downloading http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz to ./MNIST\raw\train-images-idx3-ubyte.gz
HTTP Error 403: Forbidden
Stack trace:
> File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\Lib\urllib\request.py", line 650, in http_error_default
> raise HTTPError(req.full_url, code, msg, hdrs, fp)
Using the suggestion mentioned here, adding this to the top of my script worked:
from six.moves import urllib
opener = urllib.request.build_opener()
opener.addheaders = [('User-agent', 'Mozilla/5.0')]
urllib.request.install_opener(opener)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With