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

Method __init__

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

Source from the content-addressed store, hash-verified

404 """
405
406 def __init__(self,
407 embed_dims,
408 num_heads,
409 feedforward_channels,
410 depth,
411 window_size=7,
412 qkv_bias=True,
413 qk_scale=None,
414 drop_rate=0.,
415 attn_drop_rate=0.,
416 drop_path_rate=0.,
417 downsample=None,
418 act_cfg=dict(type='GELU'),
419 norm_cfg=dict(type='LN'),
420 with_cp=False,
421 init_cfg=None):
422 super().__init__(init_cfg=init_cfg)
423
424 if isinstance(drop_path_rate, list):
425 drop_path_rates = drop_path_rate
426 assert len(drop_path_rates) == depth
427 else:
428 drop_path_rates = [deepcopy(drop_path_rate) for _ in range(depth)]
429
430 self.blocks = ModuleList()
431 for i in range(depth):
432 block = SwinBlock(
433 embed_dims=embed_dims,
434 num_heads=num_heads,
435 feedforward_channels=feedforward_channels,
436 window_size=window_size,
437 shift=False if i % 2 == 0 else True,
438 qkv_bias=qkv_bias,
439 qk_scale=qk_scale,
440 drop_rate=drop_rate,
441 attn_drop_rate=attn_drop_rate,
442 drop_path_rate=drop_path_rates[i],
443 act_cfg=act_cfg,
444 norm_cfg=norm_cfg,
445 with_cp=with_cp,
446 init_cfg=None)
447 self.blocks.append(block)
448
449 self.downsample = downsample
450
451 def forward(self, x, hw_shape):
452 for block in self.blocks:

Callers

nothing calls this directly

Calls 2

SwinBlockClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected