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

Method _init_weights

modules/VIPTRv1.py:944–954  ·  view source on GitHub ↗
(self, m)

Source from the content-addressed store, hash-verified

942 self.apply(self._init_weights)
943
944 def _init_weights(self, m):
945 if isinstance(m, nn.Linear):
946 trunc_normal_(m.weight, std=.02)
947 if isinstance(m, nn.Linear) and m.bias is not None:
948 nn.init.constant_(m.bias, 0)
949 elif isinstance(m, (nn.LayerNorm, nn.BatchNorm2d)):
950 try:
951 nn.init.constant_(m.bias, 0)
952 nn.init.constant_(m.weight, 1.0)
953 except:
954 pass
955
956 def forward_features(self, x):
957 x = self.patch_embed(x)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected