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

move out zero grad logic into separate function #969

Closed
wants to merge 1 commit into from

Conversation

JKSenthil
Copy link
Contributor

Summary:

Context

Currently it isn't possible to log gradients from AutoUnit as they are zeroed out before on_train_step_end() is reached.

This Diff

Moves out the zeroed grad from the _update_weights and into it's own function. Can be overridden, ie

class MyAutoUnit(AutoUnit):
    ...

    def zero_grad(self) ->
        self.logger.log(self.module.grad)
        super().zero_grad()

to log the gradients prior to zeroing them out

Reviewed By: galrotem

Differential Revision: D68983117

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D68983117

Summary:

# Context

Currently it isn't possible to log gradients from AutoUnit as they are zeroed out before `on_train_step_end()` is reached. 

# This Diff

Moves out the zeroed grad from the `_update_weights` and into it's own function. Can be overridden, ie
```
class MyAutoUnit(AutoUnit):
    ...

    def zero_grad(self) ->
        self.logger.log(self.module.grad)
        super().zero_grad()
```
to log the gradients prior to zeroing them out

Reviewed By: galrotem, diego-urgell

Differential Revision: D68983117
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D68983117

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

Successfully merging this pull request may close these issues.

2 participants