Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model initialization exception #19

Open
wangqiim opened this issue Sep 16, 2021 · 0 comments
Open

Model initialization exception #19

wangqiim opened this issue Sep 16, 2021 · 0 comments

Comments

@wangqiim
Copy link

Thanks for sharing your code. I find some anomalous code In msdnet.py#L322.
these three "if branch" will not be excuted in func _init_weights(self, m).

for m in self.blocks:
if hasattr(m, '__iter__'):
for _m in m:
self._init_weights(_m)
else:
self._init_weights(m)
for m in self.classifier:
if hasattr(m, '__iter__'):
for _m in m:
self._init_weights(_m)
else:
self._init_weights(m)
def _init_weights(self, m):
if isinstance(m, nn.Conv2d):
n = m.kernel_size[0] * m.kernel_size[1] * m.out_channels
m.weight.data.normal_(0, math.sqrt(2. / n))
elif isinstance(m, nn.BatchNorm2d):
m.weight.data.fill_(1)
m.bias.data.zero_()
elif isinstance(m, nn.Linear):
m.bias.data.zero_()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant