MCPcopy Create free account
hub / github.com/buaacxf/VIPTR / _init_weights

Method _init_weights

modules/VIPTRv2.py:1006–1016  ·  view source on GitHub ↗
(self, m)

Source from the content-addressed store, hash-verified

1004 self.apply(self._init_weights)
1005
1006 def _init_weights(self, m):
1007 if isinstance(m, nn.Linear):
1008 trunc_normal_(m.weight, std=.02)
1009 if isinstance(m, nn.Linear) and m.bias is not None:
1010 nn.init.constant_(m.bias, 0)
1011 elif isinstance(m, (nn.LayerNorm, nn.BatchNorm2d)):
1012 try:
1013 nn.init.constant_(m.bias, 0)
1014 nn.init.constant_(m.weight, 1.0)
1015 except:
1016 pass
1017
1018 def forward_features(self, x):
1019 x = self.patch_embed(x)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected