Skip to content

Commit dba12e1

Browse files
author
Alex Sablayrolles
committed
Fix reshape/view to make expanded weights happy
1 parent f0975c2 commit dba12e1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

opacus/optimizers/optimizer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ def clip_and_accumulate(self):
395395
"""
396396

397397
per_param_norms = [
398-
g.view(len(g), -1).norm(2, dim=-1) for g in self.grad_samples
398+
g.reshape(len(g), -1).norm(2, dim=-1) for g in self.grad_samples
399399
]
400400
per_sample_norms = torch.stack(per_param_norms, dim=1).norm(2, dim=1)
401401
per_sample_clip_factor = (self.max_grad_norm / (per_sample_norms + 1e-6)).clamp(

0 commit comments

Comments
 (0)