Skip to content
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

A bug in the tutorial building_image_classifier.ipynb #54

Closed
mmalekzadeh opened this issue Sep 6, 2020 · 1 comment
Closed

A bug in the tutorial building_image_classifier.ipynb #54

mmalekzadeh opened this issue Sep 6, 2020 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@mmalekzadeh
Copy link
Contributor

mmalekzadeh commented Sep 6, 2020

According to the description of the virtual_step(self) method in the following line

>>> optimizer.zero_grad()

the command optimizer.zero_grad() should be called after a real step and not at each step.

In the current tutorial, the command optimizer.zero_grad() is called for every step (real or virtual) which seems to be wrong.

" optimizer.zero_grad()\n",

This line (optimizer.zero_grad()) should be moved and placed right after optimizer.step()

@Darktex Darktex added the bug Something isn't working label Sep 10, 2020
@Darktex
Copy link
Contributor

Darktex commented Sep 10, 2020

Yes, this looks like a bug. Thank you for reporting!

facebook-github-bot pushed a commit that referenced this issue Sep 14, 2020
Summary:
See #54

As correctly pointed out, we don't need to call `optimizer.zero_grad()` after virtual steps, only after real steps.

Curiously, it doesn't seem to affect the accuracy:
**Claimed in the tutorial**: 56.61
**This diff**: 58.54
**Re-run of the original**: 59.12

I think we need longer training to claim stable result, but in the meantime this change
a) doesn't make things worse
b) does make sense

Reviewed By: sayanghosh

Differential Revision: D23650453

fbshipit-source-id: ec1b49b10c9b1467428d46ae298f2ad0e8d142f8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants