Iam not able to download dataset from torchvision

44_Pashikanti_Pranit: <p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/2/c/2c788e56e647480c50dc37962745ae0419b6d174.png" data-download-href="https://discuss.pytorch.org/uploads/default/2c788e56e647480c50dc37962745ae0419b6d174" title="Screenshot (243)"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/2/c/2c788e56e647480c50dc37962745ae0419b6d174_2_690x388.png" alt="Screenshot (243)" data-base62-sha1="6lpiwsDNX4uFeHYqK0kZh06VOug" width="690" height="388" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/2/c/2c788e56e647480c50dc37962745ae0419b6d174_2_690x388.png, https://discuss.pytorch.org/uploads/default/optimized/3X/2/c/2c788e56e647480c50dc37962745ae0419b6d174_2_1035x582.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/2/c/2c788e56e647480c50dc37962745ae0419b6d174_2_1380x776.png 2x" data-dominant-color="201C23"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">Screenshot (243)</span><span class="informations">1920×1080 232 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>dataset=torchvision.datasets.MNIST(root=“data/”,download=True,transform=torchvision.transforms.ToTensor())</p>
<h2><a name="downloading-httpyannlecuncomexdbmnisttrain-images-idx3-ubytegz-to-data_nnmnistrawtrain-images-idx3-ubytegz-0-0000-its-1" class="anchor" href="#downloading-httpyannlecuncomexdbmnisttrain-images-idx3-ubytegz-to-data_nnmnistrawtrain-images-idx3-ubytegz-0-0000-its-1"></a>Downloading <a href="http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz" rel="noopener nofollow ugc">http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz</a> to data_nn/MNIST/raw/train-images-idx3-ubyte.gz<br>
0/? [00:00&lt;?, ?it/s]</h2>
<p>HTTPError                                 Traceback (most recent call last)<br>
 in ()<br>
----&gt; 1 dataset = torchvision.datasets.MNIST(“data_nn/”,download=True,transform=torchvision.transforms.ToTensor())</p>
<p>11 frames<br>
/usr/lib/python3.7/urllib/request.py in http_error_default(self, req, fp, code, msg, hdrs)<br>
647 class HTTPDefaultErrorHandler(BaseHandler):<br>
648     def http_error_default(self, req, fp, code, msg, hdrs):<br>
 → 649         raise HTTPError(req.full_url, code, msg, hdrs, fp)<br>
650<br>
651 class HTTPRedirectHandler(BaseHandler):</p>
<p>HTTPError: HTTP Error 403: Forbidden</p>

ptrblck: <p>I can successfully download the dataset in a browser, but get the same <code>403 forbidden</code> error via <code>torchvision</code>.<br>
The issue is also described <a href="https://github.com/pytorch/vision/issues/3497">here</a> with a quick fix by <a class="mention" href="/u/pmeier">@pmeier</a> <a href="https://github.com/pytorch/vision/pull/3498">here</a>.<br>
You could download the nightly (once it’s available) and rerun it.</p>

44_Pashikanti_Pranit: <p>Thanks, for your help you have cleared this issue.<br>
thanks allot!!!</p>

Rampal_Singh: <p><a href="https://stackoverflow.com/questions/66577151/http-error-when-trying-to-download-mnist-data" rel="noopener nofollow ugc">find more:- </a></p>
<h1>
<a name="import-torchvision-1" class="anchor" href="#import-torchvision-1"></a>import torchvision</h1>
<p>import torchvision</p>
<h1>
<a name="import-mnist-datasets-and-transforms-2" class="anchor" href="#import-mnist-datasets-and-transforms-2"></a>import MNIST datasets and transforms</h1>
<p>from torchvision.datasets import MNIST<br>
from torchvision import transforms</p>
<p>transform = transforms.Compose([transforms.ToTensor(),<br>
transforms.Normalize((0.5,), (0.5,)),<br>
])</p>
<h1>
<a name="download-training-dataset-3" class="anchor" href="#download-training-dataset-3"></a>download training dataset</h1>
<p>train_ds = MNIST(root=“data”, download=True, transform=transform)</p>

44_Pashikanti_Pranit: <p>Check this link for refernce <a href="https://colab.research.google.com/drive/1_I8dI2hcv08HSbV5_JJMwGCYqmp_wXnO" rel="noopener nofollow ugc">here</a></p>

Novin_Nouri: <p>you can download from this <a href="https://www.kaggle.com/datasets/novinnouri/mnist-dataset/data" rel="noopener nofollow ugc">link</a></p>