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

Method _init_weights

modules/SVTR.py:539–549  ·  view source on GitHub ↗
(self, m)

Source from the content-addressed store, hash-verified

537 self.apply(self._init_weights)
538
539 def _init_weights(self, m):
540 if isinstance(m, nn.Linear):
541 # init.kaiming_uniform_(m.weight)
542 m.weight.data = truncated_normal_(m.weight.data)
543 if isinstance(m, nn.Linear) and m.bias is not None:
544 init.zeros_(m.bias)
545 elif isinstance(m, nn.LayerNorm):
546 init.zeros_(m.bias)
547 init.ones_(m.weight)
548 elif isinstance(m, nn.Conv2d):
549 init.kaiming_uniform_(m.weight)
550
551 def forward_features(self, x):
552 x = self.patch_embed(x)

Callers

nothing calls this directly

Calls 1

truncated_normal_Function · 0.85

Tested by

no test coverage detected