Skip to content

Commit

Permalink
Fixed EWC bug in importances
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreaCossu committed Jul 28, 2022
1 parent 5064e77 commit 555de3d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions avalanche/training/plugins/ewc.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def before_backward(self, strategy, **kwargs):
# dynamic models may add new units
# new units are ignored by the regularization
n_units = saved_param.shape[0]
cur_param = saved_param[:n_units]
cur_param = cur_param[:n_units]
penalty += (imp * (cur_param - saved_param).pow(2)).sum()
elif self.mode == "online":
prev_exp = exp_counter - 1
Expand All @@ -101,7 +101,7 @@ def before_backward(self, strategy, **kwargs):
# dynamic models may add new units
# new units are ignored by the regularization
n_units = saved_param.shape[0]
cur_param = saved_param[:n_units]
cur_param = cur_param[:n_units]
penalty += (imp * (cur_param - saved_param).pow(2)).sum()
else:
raise ValueError("Wrong EWC mode.")
Expand Down

0 comments on commit 555de3d

Please sign in to comment.