Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTPError: HTTP Error 403: Forbidden on Google Colab

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.

like image 676
Dipam7 Avatar asked Mar 05 '20 04:03

Dipam7


1 Answers

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.

like image 66
jakevdp Avatar answered Sep 19 '22 12:09

jakevdp