"git@developer.sourcefind.cn:OpenDAS/vision.git" did not exist on "32e16805a17401f5ef5ec825c808d645f5c26509"
Unverified Commit 0f971f64 authored by YosuaMichael's avatar YosuaMichael Committed by GitHub
Browse files

Fix bug by checking if norm_layer weight is None before init (#6082)

parent 7b28442b
...@@ -217,9 +217,9 @@ class ResNet(nn.Module): ...@@ -217,9 +217,9 @@ class ResNet(nn.Module):
# This improves the model by 0.2~0.3% according to https://arxiv.org/abs/1706.02677 # This improves the model by 0.2~0.3% according to https://arxiv.org/abs/1706.02677
if zero_init_residual: if zero_init_residual:
for m in self.modules(): for m in self.modules():
if isinstance(m, Bottleneck): if isinstance(m, Bottleneck) and m.bn3.weight is not None:
nn.init.constant_(m.bn3.weight, 0) # type: ignore[arg-type] nn.init.constant_(m.bn3.weight, 0) # type: ignore[arg-type]
elif isinstance(m, BasicBlock): elif isinstance(m, BasicBlock) and m.bn2.weight is not None:
nn.init.constant_(m.bn2.weight, 0) # type: ignore[arg-type] nn.init.constant_(m.bn2.weight, 0) # type: ignore[arg-type]
def _make_layer( def _make_layer(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment