MCPcopy Create free account
hub / github.com/NVlabs/SegFormer / init_weights

Method init_weights

mmseg/models/segmentors/encoder_decoder.py:59–75  ·  view source on GitHub ↗

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

(self, pretrained=None)

Source from the content-addressed store, hash-verified

57 self.auxiliary_head = builder.build_head(auxiliary_head)
58
59 def init_weights(self, pretrained=None):
60 """Initialize the weights in backbone and heads.
61
62 Args:
63 pretrained (str, optional): Path to pre-trained weights.
64 Defaults to None.
65 """
66
67 super(EncoderDecoder, self).init_weights(pretrained)
68 self.backbone.init_weights(pretrained=pretrained)
69 self.decode_head.init_weights()
70 if self.with_auxiliary_head:
71 if isinstance(self.auxiliary_head, nn.ModuleList):
72 for aux_head in self.auxiliary_head:
73 aux_head.init_weights()
74 else:
75 self.auxiliary_head.init_weights()
76
77 def extract_feat(self, img):
78 """Extract features from images."""

Callers 1

__init__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected