MCPcopy Create free account
hub / github.com/SLDGroup/EMCAD / __init__

Method __init__

lib/pvtv2.py:114–128  ·  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, sr_ratio=1)

Source from the content-addressed store, hash-verified

112class Block(nn.Module):
113
114 def __init__(self, dim, num_heads, mlp_ratio=4., qkv_bias=False, qk_scale=None, drop=0., attn_drop=0.,
115 drop_path=0., act_layer=nn.GELU, norm_layer=nn.LayerNorm, sr_ratio=1):
116 super().__init__()
117 self.norm1 = norm_layer(dim)
118 self.attn = Attention(
119 dim,
120 num_heads=num_heads, qkv_bias=qkv_bias, qk_scale=qk_scale,
121 attn_drop=attn_drop, proj_drop=drop, sr_ratio=sr_ratio)
122 # NOTE: drop path for stochastic depth, we shall see if this is better than dropout here
123 self.drop_path = DropPath(drop_path) if drop_path > 0. else nn.Identity()
124 self.norm2 = norm_layer(dim)
125 mlp_hidden_dim = int(dim * mlp_ratio)
126 self.mlp = Mlp(in_features=dim, hidden_features=mlp_hidden_dim, act_layer=act_layer, drop=drop)
127
128 self.apply(self._init_weights)
129
130 def _init_weights(self, m):
131 if isinstance(m, nn.Linear):

Callers

nothing calls this directly

Calls 3

AttentionClass · 0.85
MlpClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected