Skip to content

Commit 7e8cc71

Browse files
Merge pull request #315 from mitchjablonski/maj_fix_download
add work around for pytorch downloading mnist data
2 parents cacb2d2 + 1ebb724 commit 7e8cc71

11 files changed

+296
-81
lines changed

autoencoder/convolutional-autoencoder/Convolutional_Autoencoder_Exercise.ipynb

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,21 @@
2121
"Let's get started by importing our libraries and getting the dataset."
2222
]
2323
},
24+
{
25+
"cell_type": "code",
26+
"execution_count": null,
27+
"metadata": {},
28+
"outputs": [],
29+
"source": [
30+
"# The MNIST datasets are hosted on yann.lecun.com that has moved under CloudFlare protection\n",
31+
"# Run this script to enable the datasets download\n",
32+
"# Reference: https://github.com/pytorch/vision/issues/1938\n",
33+
"from six.moves import urllib\n",
34+
"opener = urllib.request.build_opener()\n",
35+
"opener.addheaders = [('User-agent', 'Mozilla/5.0')]\n",
36+
"urllib.request.install_opener(opener)"
37+
]
38+
},
2439
{
2540
"cell_type": "code",
2641
"execution_count": null,
@@ -38,9 +53,9 @@
3853
"transform = transforms.ToTensor()\n",
3954
"\n",
4055
"# load the training and test datasets\n",
41-
"train_data = datasets.MNIST(root='data', train=True,\n",
56+
"train_data = datasets.MNIST(root='~/.pytorch/MNIST_data/', train=True,\n",
4257
" download=True, transform=transform)\n",
43-
"test_data = datasets.MNIST(root='data', train=False,\n",
58+
"test_data = datasets.MNIST(root='~/.pytorch/MNIST_data/', train=False,\n",
4459
" download=True, transform=transform)"
4560
]
4661
},
@@ -282,7 +297,7 @@
282297
],
283298
"metadata": {
284299
"kernelspec": {
285-
"display_name": "Python [default]",
300+
"display_name": "Python 3",
286301
"language": "python",
287302
"name": "python3"
288303
},
@@ -296,7 +311,7 @@
296311
"name": "python",
297312
"nbconvert_exporter": "python",
298313
"pygments_lexer": "ipython3",
299-
"version": "3.6.4"
314+
"version": "3.7.1"
300315
}
301316
},
302317
"nbformat": 4,

autoencoder/convolutional-autoencoder/Convolutional_Autoencoder_Solution.ipynb

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,21 @@
2121
"Let's get started by importing our libraries and getting the dataset."
2222
]
2323
},
24+
{
25+
"cell_type": "code",
26+
"execution_count": null,
27+
"metadata": {},
28+
"outputs": [],
29+
"source": [
30+
"# The MNIST datasets are hosted on yann.lecun.com that has moved under CloudFlare protection\n",
31+
"# Run this script to enable the datasets download\n",
32+
"# Reference: https://github.com/pytorch/vision/issues/1938\n",
33+
"from six.moves import urllib\n",
34+
"opener = urllib.request.build_opener()\n",
35+
"opener.addheaders = [('User-agent', 'Mozilla/5.0')]\n",
36+
"urllib.request.install_opener(opener)"
37+
]
38+
},
2439
{
2540
"cell_type": "code",
2641
"execution_count": 1,
@@ -38,9 +53,9 @@
3853
"transform = transforms.ToTensor()\n",
3954
"\n",
4055
"# load the training and test datasets\n",
41-
"train_data = datasets.MNIST(root='data', train=True,\n",
56+
"train_data = datasets.MNIST(root='~/.pytorch/MNIST_data/', train=True,\n",
4257
" download=True, transform=transform)\n",
43-
"test_data = datasets.MNIST(root='data', train=False,\n",
58+
"test_data = datasets.MNIST(root='~/.pytorch/MNIST_data/', train=False,\n",
4459
" download=True, transform=transform)"
4560
]
4661
},
@@ -373,7 +388,7 @@
373388
],
374389
"metadata": {
375390
"kernelspec": {
376-
"display_name": "Python [default]",
391+
"display_name": "Python 3",
377392
"language": "python",
378393
"name": "python3"
379394
},
@@ -387,7 +402,7 @@
387402
"name": "python",
388403
"nbconvert_exporter": "python",
389404
"pygments_lexer": "ipython3",
390-
"version": "3.6.4"
405+
"version": "3.7.1"
391406
}
392407
},
393408
"nbformat": 4,

autoencoder/convolutional-autoencoder/Upsampling_Solution.ipynb

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,21 @@
2121
"Let's get started by importing our libraries and getting the dataset."
2222
]
2323
},
24+
{
25+
"cell_type": "code",
26+
"execution_count": null,
27+
"metadata": {},
28+
"outputs": [],
29+
"source": [
30+
"# The MNIST datasets are hosted on yann.lecun.com that has moved under CloudFlare protection\n",
31+
"# Run this script to enable the datasets download\n",
32+
"# Reference: https://github.com/pytorch/vision/issues/1938\n",
33+
"from six.moves import urllib\n",
34+
"opener = urllib.request.build_opener()\n",
35+
"opener.addheaders = [('User-agent', 'Mozilla/5.0')]\n",
36+
"urllib.request.install_opener(opener)"
37+
]
38+
},
2439
{
2540
"cell_type": "code",
2641
"execution_count": 1,
@@ -38,9 +53,9 @@
3853
"transform = transforms.ToTensor()\n",
3954
"\n",
4055
"# load the training and test datasets\n",
41-
"train_data = datasets.MNIST(root='data', train=True,\n",
56+
"train_data = datasets.MNIST(root='~/.pytorch/MNIST_data/', train=True,\n",
4257
" download=True, transform=transform)\n",
43-
"test_data = datasets.MNIST(root='data', train=False,\n",
58+
"test_data = datasets.MNIST(root='~/.pytorch/MNIST_data/', train=False,\n",
4459
" download=True, transform=transform)"
4560
]
4661
},
@@ -365,7 +380,7 @@
365380
],
366381
"metadata": {
367382
"kernelspec": {
368-
"display_name": "Python [default]",
383+
"display_name": "Python 3",
369384
"language": "python",
370385
"name": "python3"
371386
},
@@ -379,7 +394,7 @@
379394
"name": "python",
380395
"nbconvert_exporter": "python",
381396
"pygments_lexer": "ipython3",
382-
"version": "3.6.4"
397+
"version": "3.7.1"
383398
}
384399
},
385400
"nbformat": 4,

autoencoder/denoising-autoencoder/Denoising_Autoencoder_Exercise.ipynb

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,21 @@
1313
"Let's get started by importing our libraries and getting the dataset."
1414
]
1515
},
16+
{
17+
"cell_type": "code",
18+
"execution_count": null,
19+
"metadata": {},
20+
"outputs": [],
21+
"source": [
22+
"# The MNIST datasets are hosted on yann.lecun.com that has moved under CloudFlare protection\n",
23+
"# Run this script to enable the datasets download\n",
24+
"# Reference: https://github.com/pytorch/vision/issues/1938\n",
25+
"from six.moves import urllib\n",
26+
"opener = urllib.request.build_opener()\n",
27+
"opener.addheaders = [('User-agent', 'Mozilla/5.0')]\n",
28+
"urllib.request.install_opener(opener)"
29+
]
30+
},
1631
{
1732
"cell_type": "code",
1833
"execution_count": null,
@@ -30,9 +45,9 @@
3045
"transform = transforms.ToTensor()\n",
3146
"\n",
3247
"# load the training and test datasets\n",
33-
"train_data = datasets.MNIST(root='data', train=True,\n",
48+
"train_data = datasets.MNIST(root='~/.pytorch/MNIST_data/', train=True,\n",
3449
" download=True, transform=transform)\n",
35-
"test_data = datasets.MNIST(root='data', train=False,\n",
50+
"test_data = datasets.MNIST(root='~/.pytorch/MNIST_data/', train=False,\n",
3651
" download=True, transform=transform)\n",
3752
"\n",
3853
"# Create training and test dataloaders\n",
@@ -273,7 +288,7 @@
273288
],
274289
"metadata": {
275290
"kernelspec": {
276-
"display_name": "Python [default]",
291+
"display_name": "Python 3",
277292
"language": "python",
278293
"name": "python3"
279294
},
@@ -287,7 +302,7 @@
287302
"name": "python",
288303
"nbconvert_exporter": "python",
289304
"pygments_lexer": "ipython3",
290-
"version": "3.6.4"
305+
"version": "3.7.1"
291306
}
292307
},
293308
"nbformat": 4,

autoencoder/denoising-autoencoder/Denoising_Autoencoder_Solution.ipynb

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,21 @@
1313
"Let's get started by importing our libraries and getting the dataset."
1414
]
1515
},
16+
{
17+
"cell_type": "code",
18+
"execution_count": null,
19+
"metadata": {},
20+
"outputs": [],
21+
"source": [
22+
"# The MNIST datasets are hosted on yann.lecun.com that has moved under CloudFlare protection\n",
23+
"# Run this script to enable the datasets download\n",
24+
"# Reference: https://github.com/pytorch/vision/issues/1938\n",
25+
"from six.moves import urllib\n",
26+
"opener = urllib.request.build_opener()\n",
27+
"opener.addheaders = [('User-agent', 'Mozilla/5.0')]\n",
28+
"urllib.request.install_opener(opener)"
29+
]
30+
},
1631
{
1732
"cell_type": "code",
1833
"execution_count": 1,
@@ -28,9 +43,9 @@
2843
"transform = transforms.ToTensor()\n",
2944
"\n",
3045
"# load the training and test datasets\n",
31-
"train_data = datasets.MNIST(root='data', train=True,\n",
46+
"train_data = datasets.MNIST(root='~/.pytorch/MNIST_data/', train=True,\n",
3247
" download=True, transform=transform)\n",
33-
"test_data = datasets.MNIST(root='data', train=False,\n",
48+
"test_data = datasets.MNIST(root='~/.pytorch/MNIST_data/', train=False,\n",
3449
" download=True, transform=transform)\n",
3550
"\n",
3651
"# Create training and test dataloaders\n",
@@ -369,7 +384,7 @@
369384
],
370385
"metadata": {
371386
"kernelspec": {
372-
"display_name": "Python [default]",
387+
"display_name": "Python 3",
373388
"language": "python",
374389
"name": "python3"
375390
},
@@ -383,7 +398,7 @@
383398
"name": "python",
384399
"nbconvert_exporter": "python",
385400
"pygments_lexer": "ipython3",
386-
"version": "3.6.4"
401+
"version": "3.7.1"
387402
}
388403
},
389404
"nbformat": 4,

autoencoder/linear-autoencoder/Simple_Autoencoder_Exercise.ipynb

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,21 @@
1919
"In this notebook, we'll be build a simple network architecture for the encoder and decoder. Let's get started by importing our libraries and getting the dataset."
2020
]
2121
},
22+
{
23+
"cell_type": "code",
24+
"execution_count": null,
25+
"metadata": {},
26+
"outputs": [],
27+
"source": [
28+
"# The MNIST datasets are hosted on yann.lecun.com that has moved under CloudFlare protection\n",
29+
"# Run this script to enable the datasets download\n",
30+
"# Reference: https://github.com/pytorch/vision/issues/1938\n",
31+
"from six.moves import urllib\n",
32+
"opener = urllib.request.build_opener()\n",
33+
"opener.addheaders = [('User-agent', 'Mozilla/5.0')]\n",
34+
"urllib.request.install_opener(opener)"
35+
]
36+
},
2237
{
2338
"cell_type": "code",
2439
"execution_count": null,
@@ -36,9 +51,9 @@
3651
"transform = transforms.ToTensor()\n",
3752
"\n",
3853
"# load the training and test datasets\n",
39-
"train_data = datasets.MNIST(root='data', train=True,\n",
54+
"train_data = datasets.MNIST(root='~/.pytorch/MNIST_data/', train=True,\n",
4055
" download=True, transform=transform)\n",
41-
"test_data = datasets.MNIST(root='data', train=False,\n",
56+
"test_data = datasets.MNIST(root='~/.pytorch/MNIST_data/', train=False,\n",
4257
" download=True, transform=transform)"
4358
]
4459
},
@@ -267,9 +282,7 @@
267282
},
268283
{
269284
"cell_type": "markdown",
270-
"metadata": {
271-
"collapsed": true
272-
},
285+
"metadata": {},
273286
"source": [
274287
"## Up Next\n",
275288
"\n",
@@ -279,7 +292,7 @@
279292
],
280293
"metadata": {
281294
"kernelspec": {
282-
"display_name": "Python [default]",
295+
"display_name": "Python 3",
283296
"language": "python",
284297
"name": "python3"
285298
},
@@ -293,7 +306,7 @@
293306
"name": "python",
294307
"nbconvert_exporter": "python",
295308
"pygments_lexer": "ipython3",
296-
"version": "3.6.4"
309+
"version": "3.7.1"
297310
}
298311
},
299312
"nbformat": 4,

autoencoder/linear-autoencoder/Simple_Autoencoder_Solution.ipynb

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,21 @@
1919
"In this notebook, we'll be build a simple network architecture for the encoder and decoder. Let's get started by importing our libraries and getting the dataset."
2020
]
2121
},
22+
{
23+
"cell_type": "code",
24+
"execution_count": null,
25+
"metadata": {},
26+
"outputs": [],
27+
"source": [
28+
"# The MNIST datasets are hosted on yann.lecun.com that has moved under CloudFlare protection\n",
29+
"# Run this script to enable the datasets download\n",
30+
"# Reference: https://github.com/pytorch/vision/issues/1938\n",
31+
"from six.moves import urllib\n",
32+
"opener = urllib.request.build_opener()\n",
33+
"opener.addheaders = [('User-agent', 'Mozilla/5.0')]\n",
34+
"urllib.request.install_opener(opener)"
35+
]
36+
},
2237
{
2338
"cell_type": "code",
2439
"execution_count": 1,
@@ -36,9 +51,9 @@
3651
"transform = transforms.ToTensor()\n",
3752
"\n",
3853
"# load the training and test datasets\n",
39-
"train_data = datasets.MNIST(root='data', train=True,\n",
54+
"train_data = datasets.MNIST(root='~/.pytorch/MNIST_data/', train=True,\n",
4055
" download=True, transform=transform)\n",
41-
"test_data = datasets.MNIST(root='data', train=False,\n",
56+
"test_data = datasets.MNIST(root='~/.pytorch/MNIST_data/', train=False,\n",
4257
" download=True, transform=transform)"
4358
]
4459
},
@@ -336,9 +351,7 @@
336351
},
337352
{
338353
"cell_type": "markdown",
339-
"metadata": {
340-
"collapsed": true
341-
},
354+
"metadata": {},
342355
"source": [
343356
"## Up Next\n",
344357
"\n",
@@ -348,7 +361,7 @@
348361
],
349362
"metadata": {
350363
"kernelspec": {
351-
"display_name": "Python [default]",
364+
"display_name": "Python 3",
352365
"language": "python",
353366
"name": "python3"
354367
},
@@ -362,7 +375,7 @@
362375
"name": "python",
363376
"nbconvert_exporter": "python",
364377
"pygments_lexer": "ipython3",
365-
"version": "3.6.4"
378+
"version": "3.7.1"
366379
}
367380
},
368381
"nbformat": 4,

0 commit comments

Comments
 (0)