HTTPError: HTTP Error 403: Forbidden on Google Colab

Dipam7 :

I am trying to download MNIST data in PyTorch using the following code:

train_loader = torch.utils.data.DataLoader(
      datasets.MNIST('data',
                      train=True,
                      download=True,
                      transform=transforms.Compose([
                         transforms.ToTensor(),
                         transforms.Normalize((0.1307,), (0.3081,))
                     ])),
      batch_size=128, shuffle=True)

and it gives the following error.

Downloading http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz to data/MNIST/raw/train-images-idx3-ubyte.gz
0it [00:00, ?it/s]
---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
<ipython-input-2-2fee284dabb8> in <module>()
      5                       transform=transforms.Compose([
      6                          transforms.ToTensor(),
----> 7                          transforms.Normalize((0.1307,), (0.3081,))
      8                      ])),
      9       batch_size=128, shuffle=True)

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

HTTPError: HTTP Error 403: Forbidden

How do I solve this? The notebook was working before, I'm trying to rerun it but I got this error.

jakevdp :

This is a new bug, reported here: https://github.com/pytorch/vision/issues/1938

See that thread for some potential workarounds until the issue is fixed in pytorch itself.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=25629&siteId=1