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

Gradient accumulation not properly implemented #53

Open
clemsgrs opened this issue Jul 14, 2023 · 2 comments
Open

Gradient accumulation not properly implemented #53

clemsgrs opened this issue Jul 14, 2023 · 2 comments

Comments

@clemsgrs
Copy link

clemsgrs commented Jul 14, 2023

Hi, based on the following lines, it seems gradient accumulation is not properly implemented:

loss = loss / gc
loss.backward()
# step
optimizer.step()
optimizer.zero_grad()

A proper implementation should look like the following:

loss = loss / gc
loss.backward()

if (batch_idx + 1) % gc == 0:
      optimizer.step()
      optimizer.zero_grad()
@vildesboe
Copy link

Hi, based on the following lines, it seems gradient accumulation is not properly implemented:

loss = loss / gc
loss.backward()
# step
optimizer.step()
optimizer.zero_grad()

A proper implementation should look like the following:

loss = loss / gc
loss.backward()

if (batch_idx + 1) % gc == 0:
      optimizer.step()
      optimizer.zero_grad()

Hi! I'm also working on reproducing this HIPT paper. Would you be interested in some discussion?

@clemsgrs
Copy link
Author

sure, happy to chat.
I’ve made my own version of the code here: https://github.com/clemsgrs/hipt

you can contact me at: clement (dot) grisi (at) radboudumc (dot) nl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants