Skip to content

Commit

Permalink
Merge pull request #7 from tinyzqh/main
Browse files Browse the repository at this point in the history
fix index of num_features_to_replace bug
  • Loading branch information
shibhansh authored Nov 3, 2024
2 parents 7bf3dfe + d096af7 commit 63c35f3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lop/algos/convGnT.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def update_optim_params(self, features_to_replace_input_indices, features_to_rep
if self.opt_type == 'AdamGnT':
for i in range(self.num_hidden_layers):
# input weights
if num_features_to_replace == 0:
if num_features_to_replace[i] == 0:
continue
# input weights
self.opt.state[self.net[i * 2].bias]['exp_avg'][features_to_replace_input_indices[i]] = 0.0
Expand Down
2 changes: 1 addition & 1 deletion lop/algos/gnt.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def update_optim_params(self, features_to_replace, num_features_to_replace):
if self.opt_type == 'adam':
for i in range(self.num_hidden_layers):
# input weights
if num_features_to_replace == 0:
if num_features_to_replace[i] == 0:
continue
self.opt.state[self.net[i * 2].weight]['exp_avg'][features_to_replace[i], :] = 0.0
self.opt.state[self.net[i * 2].bias]['exp_avg'][features_to_replace[i]] = 0.0
Expand Down

0 comments on commit 63c35f3

Please sign in to comment.