MCPcopy Create free account
hub / github.com/M2219/ESMStereo / SubModule

Class SubModule

models/ESMStereo.py:21–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19 return np.sum(np.prod(v.size()) for name, v in model.named_parameters() if "auxiliary" not in name)/1e6
20
21class SubModule(nn.Module):
22 def __init__(self) -> None:
23 super(SubModule, self).__init__()
24
25 def weight_init(self) -> None:
26 for m in self.modules():
27 if isinstance(m, nn.Conv2d):
28 n = m.kernel_size[0] * m.kernel_size[1] * m.out_channels
29 m.weight.data.normal_(0, math.sqrt(2. / n))
30 elif isinstance(m, nn.Conv3d):
31 n = m.kernel_size[0] * m.kernel_size[1] * m.kernel_size[2] * m.out_channels
32 m.weight.data.normal_(0, math.sqrt(2. / n))
33 elif isinstance(m, nn.BatchNorm2d):
34 m.weight.data.fill_(1)
35 m.bias.data.zero_()
36 elif isinstance(m, nn.BatchNorm3d):
37 m.weight.data.fill_(1)
38 m.bias.data.zero_()
39
40class Feature(SubModule):
41 def __init__(self, backbone: str) -> None:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected