From 0ace8af232f010712b290e07a22acfa1aad3c031 Mon Sep 17 00:00:00 2001 From: "Karjauv, Aray" Date: Fri, 19 Jul 2024 18:42:34 +0200 Subject: [PATCH] Fix setattr issue in canonizers.MergeBatchNorm (#208) --- src/zennit/canonizers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/zennit/canonizers.py b/src/zennit/canonizers.py index fc4a4f2..063e6ab 100644 --- a/src/zennit/canonizers.py +++ b/src/zennit/canonizers.py @@ -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)))