Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Commit

Permalink
fix gradient logging (remove hook if trainer does not exist anymore)
Browse files Browse the repository at this point in the history
  • Loading branch information
Steffen-Wolf committed Aug 9, 2019
1 parent bd63892 commit cd4de05
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions inferno/trainers/callbacks/gradients.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ def log_every(self, value):
FrequencyValueError)

def hook(self, module, grad_input, grad_output):

#remove hook if trainer does not exits
if self.trainer is None:
self.hook_handle.remove()
return

if self.log_every.match(iteration_count=self.trainer.iteration_count,
epoch_count=self.trainer.epoch_count,
persistent=True, match_zero=True):
Expand Down

0 comments on commit cd4de05

Please sign in to comment.