MCPcopy Create free account
hub / github.com/alinlab/SelfPatch / __init__

Method __init__

segmentation/backbones/swin.py:148–175  ·  view source on GitHub ↗
(self,
                 embed_dims,
                 num_heads,
                 window_size,
                 shift_size=0,
                 qkv_bias=True,
                 qk_scale=None,
                 attn_drop_rate=0,
                 proj_drop_rate=0,
                 dropout_layer=dict(type='DropPath', drop_prob=0.),
                 init_cfg=None)

Source from the content-addressed store, hash-verified

146 """
147
148 def __init__(self,
149 embed_dims,
150 num_heads,
151 window_size,
152 shift_size=0,
153 qkv_bias=True,
154 qk_scale=None,
155 attn_drop_rate=0,
156 proj_drop_rate=0,
157 dropout_layer=dict(type='DropPath', drop_prob=0.),
158 init_cfg=None):
159 super().__init__(init_cfg=init_cfg)
160
161 self.window_size = window_size
162 self.shift_size = shift_size
163 assert 0 <= self.shift_size < self.window_size
164
165 self.w_msa = WindowMSA(
166 embed_dims=embed_dims,
167 num_heads=num_heads,
168 window_size=to_2tuple(window_size),
169 qkv_bias=qkv_bias,
170 qk_scale=qk_scale,
171 attn_drop_rate=attn_drop_rate,
172 proj_drop_rate=proj_drop_rate,
173 init_cfg=None)
174
175 self.drop = build_dropout(dropout_layer)
176
177 def forward(self, query, hw_shape):
178 B, L, C = query.shape

Callers

nothing calls this directly

Calls 2

WindowMSAClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected