MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / init_weights

Method init_weights

detrsmpl/models/utils/transformer.py:394–404  ·  view source on GitHub ↗

Initialize the transformer weights.

(self)

Source from the content-addressed store, hash-verified

392 self.reference_points = nn.Linear(self.embed_dims, 2)
393
394 def init_weights(self):
395 """Initialize the transformer weights."""
396 for p in self.parameters():
397 if p.dim() > 1:
398 nn.init.xavier_uniform_(p)
399 for m in self.modules():
400 if isinstance(m, MultiScaleDeformableAttention):
401 m.init_weights()
402 if not self.as_two_stage:
403 xavier_init(self.reference_points, distribution='uniform', bias=0.)
404 normal_(self.level_embeds)
405
406 def gen_encoder_output_proposals(self, memory, memory_padding_mask,
407 spatial_shapes):

Callers

nothing calls this directly

Calls 2

parametersMethod · 0.80
init_weightsMethod · 0.45

Tested by

no test coverage detected