MCPcopy Create free account
hub / github.com/OpenGVLab/UniFormerV2 / __init__

Method __init__

slowfast/models/uniformer.py:116–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)

Source from the content-addressed store, hash-verified

114
115class CBlock(nn.Module):
116 def __init__(self, dim, num_heads, mlp_ratio=4., qkv_bias=False, qk_scale=None, drop=0., attn_drop=0.,
117 drop_path=0., act_layer=nn.GELU, norm_layer=nn.LayerNorm):
118 super().__init__()
119 self.pos_embed = conv_3x3x3(dim, dim, groups=dim)
120 self.norm1 = bn_3d(dim)
121 self.conv1 = conv_1x1x1(dim, dim, 1)
122 self.conv2 = conv_1x1x1(dim, dim, 1)
123 self.attn = conv_5x5x5(dim, dim, groups=dim)
124 # NOTE: drop path for stochastic depth, we shall see if this is better than dropout here
125 self.drop_path = DropPath(drop_path) if drop_path > 0. else nn.Identity()
126 self.norm2 = bn_3d(dim)
127 mlp_hidden_dim = int(dim * mlp_ratio)
128 self.mlp = CMlp(in_features=dim, hidden_features=mlp_hidden_dim, act_layer=act_layer, drop=drop)
129
130 def forward(self, x):
131 x = x + self.pos_embed(x)

Callers

nothing calls this directly

Calls 7

conv_3x3x3Function · 0.85
bn_3dFunction · 0.85
conv_1x1x1Function · 0.85
conv_5x5x5Function · 0.85
DropPathClass · 0.85
CMlpClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected