Skip to content

Model initialization exception #19

@wangqiim

Description

@wangqiim

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_()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions