MCPcopy Create free account
hub / github.com/UX-Decoder/Semantic-SAM / init_weights

Method init_weights

semantic_sam/backbone/swin.py:646–660  ·  view source on GitHub ↗

Initialize the weights in backbone. Args: pretrained (str, optional): Path to pre-trained weights. Defaults to None.

(self, pretrained=None)

Source from the content-addressed store, hash-verified

644 param.requires_grad = False
645
646 def init_weights(self, pretrained=None):
647 """Initialize the weights in backbone.
648 Args:
649 pretrained (str, optional): Path to pre-trained weights.
650 Defaults to None.
651 """
652
653 def _init_weights(m):
654 if isinstance(m, nn.Linear):
655 trunc_normal_(m.weight, std=0.02)
656 if isinstance(m, nn.Linear) and m.bias is not None:
657 nn.init.constant_(m.bias, 0)
658 elif isinstance(m, nn.LayerNorm):
659 nn.init.constant_(m.bias, 0)
660 nn.init.constant_(m.weight, 1.0)
661
662
663 def load_weights(self, pretrained_dict=None, pretrained_layers=[], verbose=True):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected