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

Method __init__

segmentation/backbones/mit.py:201–237  ·  view source on GitHub ↗
(self,
                 embed_dims,
                 num_heads,
                 feedforward_channels,
                 drop_rate=0.,
                 attn_drop_rate=0.,
                 drop_path_rate=0.,
                 qkv_bias=True,
                 act_cfg=dict(type='GELU'),
                 norm_cfg=dict(type='LN'),
                 batch_first=True,
                 sr_ratio=1)

Source from the content-addressed store, hash-verified

199 """
200
201 def __init__(self,
202 embed_dims,
203 num_heads,
204 feedforward_channels,
205 drop_rate=0.,
206 attn_drop_rate=0.,
207 drop_path_rate=0.,
208 qkv_bias=True,
209 act_cfg=dict(type='GELU'),
210 norm_cfg=dict(type='LN'),
211 batch_first=True,
212 sr_ratio=1):
213 super(TransformerEncoderLayer, self).__init__()
214
215 # The ret[0] of build_norm_layer is norm name.
216 self.norm1 = build_norm_layer(norm_cfg, embed_dims)[1]
217
218 self.attn = EfficientMultiheadAttention(
219 embed_dims=embed_dims,
220 num_heads=num_heads,
221 attn_drop=attn_drop_rate,
222 proj_drop=drop_rate,
223 dropout_layer=dict(type='DropPath', drop_prob=drop_path_rate),
224 batch_first=batch_first,
225 qkv_bias=qkv_bias,
226 norm_cfg=norm_cfg,
227 sr_ratio=sr_ratio)
228
229 # The ret[0] of build_norm_layer is norm name.
230 self.norm2 = build_norm_layer(norm_cfg, embed_dims)[1]
231
232 self.ffn = MixFFN(
233 embed_dims=embed_dims,
234 feedforward_channels=feedforward_channels,
235 ffn_drop=drop_rate,
236 dropout_layer=dict(type='DropPath', drop_prob=drop_path_rate),
237 act_cfg=act_cfg)
238
239 def forward(self, x, hw_shape):
240 x = self.attn(self.norm1(x), hw_shape, identity=x)

Callers

nothing calls this directly

Calls 3

MixFFNClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected