Skip to content

Commit 7449ed3

Browse files
brianjoseemethere
andauthored
Update spatial_transformer_tutorial.py (pytorch#1386)
* Update spatial_transformer_tutorial.py * Update fgsm_tutorial.py * Update beginner_source/fgsm_tutorial.py Co-authored-by: Eli Uriegas <1700823+seemethere@users.noreply.github.com> Co-authored-by: Eli Uriegas <1700823+seemethere@users.noreply.github.com>
1 parent 82d922b commit 7449ed3

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

beginner_source/fgsm_tutorial.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,13 @@
9999
import numpy as np
100100
import matplotlib.pyplot as plt
101101

102+
# NOTE: This is a hack to get around "User-agent" limitations when downloading MNIST datasets
103+
# see, https://github.com/pytorch/vision/issues/3497 for more information
104+
from six.moves import urllib
105+
opener = urllib.request.build_opener()
106+
opener.addheaders = [('User-agent', 'Mozilla/5.0')]
107+
urllib.request.install_opener(opener)
108+
102109

103110
######################################################################
104111
# Implementation
@@ -413,4 +420,3 @@ def test( model, device, test_loader, epsilon ):
413420
# it differs from FGSM. Then, try to defend the model from your own
414421
# attacks.
415422
#
416-

intermediate_source/spatial_transformer_tutorial.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@
4747
# standard convolutional network augmented with a spatial transformer
4848
# network.
4949

50+
from six.moves import urllib
51+
opener = urllib.request.build_opener()
52+
opener.addheaders = [('User-agent', 'Mozilla/5.0')]
53+
urllib.request.install_opener(opener)
54+
5055
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
5156

5257
# Training dataset

0 commit comments

Comments
 (0)