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

Method __init__

segmentation/backbones/swin.py:310–352  ·  view source on GitHub ↗
(self,
                 embed_dims,
                 num_heads,
                 feedforward_channels,
                 window_size=7,
                 shift=False,
                 qkv_bias=True,
                 qk_scale=None,
                 drop_rate=0.,
                 attn_drop_rate=0.,
                 drop_path_rate=0.,
                 act_cfg=dict(type='GELU'),
                 norm_cfg=dict(type='LN'),
                 with_cp=False,
                 init_cfg=None)

Source from the content-addressed store, hash-verified

308 """
309
310 def __init__(self,
311 embed_dims,
312 num_heads,
313 feedforward_channels,
314 window_size=7,
315 shift=False,
316 qkv_bias=True,
317 qk_scale=None,
318 drop_rate=0.,
319 attn_drop_rate=0.,
320 drop_path_rate=0.,
321 act_cfg=dict(type='GELU'),
322 norm_cfg=dict(type='LN'),
323 with_cp=False,
324 init_cfg=None):
325
326 super(SwinBlock, self).__init__(init_cfg=init_cfg)
327
328 self.with_cp = with_cp
329
330 self.norm1 = build_norm_layer(norm_cfg, embed_dims)[1]
331 self.attn = ShiftWindowMSA(
332 embed_dims=embed_dims,
333 num_heads=num_heads,
334 window_size=window_size,
335 shift_size=window_size // 2 if shift else 0,
336 qkv_bias=qkv_bias,
337 qk_scale=qk_scale,
338 attn_drop_rate=attn_drop_rate,
339 proj_drop_rate=drop_rate,
340 dropout_layer=dict(type='DropPath', drop_prob=drop_path_rate),
341 init_cfg=None)
342
343 self.norm2 = build_norm_layer(norm_cfg, embed_dims)[1]
344 self.ffn = FFN(
345 embed_dims=embed_dims,
346 feedforward_channels=feedforward_channels,
347 num_fcs=2,
348 ffn_drop=drop_rate,
349 dropout_layer=dict(type='DropPath', drop_prob=drop_path_rate),
350 act_cfg=act_cfg,
351 add_identity=True,
352 init_cfg=None)
353
354 def forward(self, x, hw_shape):
355

Callers

nothing calls this directly

Calls 2

ShiftWindowMSAClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected