Skip to content

Commit

Permalink
Fix setattr issue in canonizers.MergeBatchNorm (#208)
Browse files Browse the repository at this point in the history
  • Loading branch information
Karjauv, Aray committed Jul 19, 2024
1 parent e5699aa commit 0ace8af
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/zennit/canonizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ def merge_batch_norm(modules, batch_norm):

for module in modules:
if module.bias is None:
object.__setattr__(
module, 'bias', torch.zeros(1, device=module.weight.device, dtype=module.weight.dtype)
setattr(
module, 'bias', torch.nn.Parameter(torch.zeros(1, device=module.weight.device, dtype=module.weight.dtype))
)

index = (slice(None), *((None,) * (module.weight.ndim - 1)))
Expand Down

0 comments on commit 0ace8af

Please sign in to comment.