-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix inconsistencies in fgsm_tutorial #2419
Conversation
Model architecture was not the same as that of the one in Basic MNIST Example, so it has been changed to be the exact same
The model is trained on normalized data, so it is unfair to use unnormalized data in this example.
The MNIST model is trained with normalized data but no normalization was applied in this tutorial. Thus, a denorm function is created, which is called to denorm the data before performing FGSM. The perturbed data is again normalized before feeding it to the model.
✅ Deploy Preview for pytorch-tutorials-preview ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
the CI is failing because the tutorial relies on |
@QasimKhan5x I can update the file, but weights referenced from the tutorial are indeed for small model:
I.e. your PR should include new location to download the model in both tutorial itself as well as here: Line 85 in 47b9ea4
|
@malfet I trained a model using the pytorch/examples/mnist code. Should I upload it to my own publicly accessible S3 bucket and provide its link? |
@QasimKhan5x any public location will do, though google drive is preferable (as tutorials are most frequently run on colab, and one can connect collab to g-drive, can't they?) |
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/tutorials/2419
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit eb1338d: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
@malfet completed the changes |
Fixes #1032
Description
mean=0.1307
andstd=0.3081
. However, no normalization was being applied in this example. Thus, the same normalization is applied to thetest_loader
in this example.state_dict
of the MNIST was being loaded on the CPU even thoughuse_cuda=True
anddevice
is being dynamically defined. Therefore,map_location=device
instead ofcpu
test
function is modified. After computing the gradient of the normalized data, the data is unnormalized. FGSM is then applied on unnormalized data. Finally, the perturbed data is again normalized before applying the model on it.I also checked the code without step 5, i.e., not performing normalization and denormalization inside the
test
function. The observation was that the accuracy stayed the same between 98-99%, although it was supposed to fall. Applying step 5 rectified this issue.Checklist