Iam not able to download dataset from torchvision


Downloading http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz to data_nn/MNIST/raw/train-images-idx3-ubyte.gz
0/? [00:00<?, ?it/s]

HTTPError Traceback (most recent call last)
in ()
----> 1 dataset = torchvision.datasets.MNIST(“data_nn/”,download=True,transform=torchvision.transforms.ToTensor())

11 frames
/usr/lib/python3.7/urllib/request.py in http_error_default(self, req, fp, code, msg, hdrs)
647 class HTTPDefaultErrorHandler(BaseHandler):
648 def http_error_default(self, req, fp, code, msg, hdrs):
→ 649 raise HTTPError(req.full_url, code, msg, hdrs, fp)
651 class HTTPRedirectHandler(BaseHandler):

HTTPError: HTTP Error 403: Forbidden

I can successfully download the dataset in a browser, but get the same 403 forbidden error via torchvision.
The issue is also described here with a quick fix by @pmeier here.
You could download the nightly (once it’s available) and rerun it.

1 Like

Thanks, for your help you have cleared this issue.
thanks allot!!!

find more:-

import torchvision

import torchvision

import MNIST datasets and transforms

from torchvision.datasets import MNIST
from torchvision import transforms

transform = transforms.Compose([transforms.ToTensor(),
transforms.Normalize((0.5,), (0.5,)),

download training dataset

train_ds = MNIST(root=“data”, download=True, transform=transform)

Check this link for refernce here