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

Method __init__

selfpatch_vision_transformer.py:224–233  ·  view source on GitHub ↗
(self, dim, num_heads, mlp_ratio=4., qkv_bias=False, qk_scale=None, drop=0., attn_drop=0.,
                 drop_path=0., act_layer=nn.GELU, norm_layer=nn.LayerNorm)

Source from the content-addressed store, hash-verified

222
223class Block(nn.Module):
224 def __init__(self, dim, num_heads, mlp_ratio=4., qkv_bias=False, qk_scale=None, drop=0., attn_drop=0.,
225 drop_path=0., act_layer=nn.GELU, norm_layer=nn.LayerNorm):
226 super().__init__()
227 self.norm1 = norm_layer(dim)
228 self.attn = Attention(
229 dim, num_heads=num_heads, qkv_bias=qkv_bias, qk_scale=qk_scale, attn_drop=attn_drop, proj_drop=drop)
230 self.drop_path = DropPath(drop_path) if drop_path > 0. else nn.Identity()
231 self.norm2 = norm_layer(dim)
232 mlp_hidden_dim = int(dim * mlp_ratio)
233 self.mlp = Mlp(in_features=dim, hidden_features=mlp_hidden_dim, act_layer=act_layer, drop=drop)
234
235 def forward(self, x, return_attention=False):
236 y, attn = self.attn(self.norm1(x))

Callers

nothing calls this directly

Calls 4

AttentionClass · 0.70
DropPathClass · 0.70
MlpClass · 0.70
__init__Method · 0.45

Tested by

no test coverage detected