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

Method forward

slowfast/models/uniformer.py:184–198  ·  view source on GitHub ↗
(self, x)

Source from the content-addressed store, hash-verified

182 self.mlp = Mlp(in_features=dim, hidden_features=mlp_hidden_dim, act_layer=act_layer, drop=drop)
183
184 def forward(self, x):
185 x = x + self.pos_embed(x)
186 B, C, T, H, W = x.shape
187 attn = x.view(B, C, T, H * W).permute(0, 3, 2, 1).contiguous()
188 attn = attn.view(B * H * W, T, C)
189 attn = attn + self.drop_path(self.t_attn(self.t_norm(attn)))
190 attn = attn.view(B, H * W, T, C).permute(0, 2, 1, 3).contiguous()
191 attn = attn.view(B * T, H * W, C)
192 residual = x.view(B, C, T, H * W).permute(0, 2, 3, 1).contiguous()
193 residual = residual.view(B * T, H * W, C)
194 attn = residual + self.drop_path(self.attn(self.norm1(attn)))
195 attn = attn.view(B, T * H * W, C)
196 out = attn + self.drop_path(self.mlp(self.norm2(attn)))
197 out = out.transpose(1, 2).reshape(B, C, T, H, W)
198 return out
199
200
201class SpeicalPatchEmbed(nn.Module):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected