MCPcopy Create free account
hub / github.com/lingeringlight/START / __init__

Method __init__

models/vmamba.py:626–676  ·  view source on GitHub ↗
(
            self,
            dim,
            depth,
            attn_drop=0.,
            drop_path=0.,
            norm_layer=nn.LayerNorm,
            downsample=None,
            use_checkpoint=False,
            d_state=16,
            spatial_aug_flag=1,
            START_flag=1,
            START_p=1.0,
            START_token_prob=0.75,
            START_batch_prob=0.5,
            START_attention_mode=0,
            **kwargs,
    )

Source from the content-addressed store, hash-verified

624 """
625
626 def __init__(
627 self,
628 dim,
629 depth,
630 attn_drop=0.,
631 drop_path=0.,
632 norm_layer=nn.LayerNorm,
633 downsample=None,
634 use_checkpoint=False,
635 d_state=16,
636 spatial_aug_flag=1,
637 START_flag=1,
638 START_p=1.0,
639 START_token_prob=0.75,
640 START_batch_prob=0.5,
641 START_attention_mode=0,
642 **kwargs,
643 ):
644 super().__init__()
645 self.dim = dim
646 self.use_checkpoint = use_checkpoint
647
648 self.blocks = nn.ModuleList([
649 VSSBlock(
650 hidden_dim=dim,
651 drop_path=drop_path[i] if isinstance(drop_path, list) else drop_path,
652 norm_layer=norm_layer,
653 attn_drop_rate=attn_drop,
654 d_state=d_state,
655 spatial_aug_flag=spatial_aug_flag,
656 START_flag=START_flag,
657 START_p=START_p,
658 START_token_prob=START_token_prob,
659 START_batch_prob=START_batch_prob,
660 START_attention_mode=START_attention_mode,
661 )
662 for i in range(depth)])
663
664 if True: # is this really applied? Yes, but been overriden later in VSSM!
665 def _init_weights(module: nn.Module):
666 for name, p in module.named_parameters():
667 if name in ["out_proj.weight"]:
668 p = p.clone().detach_() # fake init, just to keep the seed ....
669 nn.init.kaiming_uniform_(p, a=math.sqrt(5))
670
671 self.apply(_init_weights)
672
673 if downsample is not None:
674 self.downsample = downsample(dim=dim, norm_layer=norm_layer)
675 else:
676 self.downsample = None
677
678 def forward(self, x):
679 for blk in self.blocks:

Callers

nothing calls this directly

Calls 2

VSSBlockClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected