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

Class PatchEmbed

slowfast/models/stem_helper.py:290–320  ·  view source on GitHub ↗

PatchEmbed.

Source from the content-addressed store, hash-verified

288
289
290class PatchEmbed(nn.Module):
291 """
292 PatchEmbed.
293 """
294
295 def __init__(
296 self,
297 dim_in=3,
298 dim_out=768,
299 kernel=(1, 16, 16),
300 stride=(1, 4, 4),
301 padding=(1, 7, 7),
302 conv_2d=False,
303 ):
304 super().__init__()
305 if conv_2d:
306 conv = nn.Conv2d
307 else:
308 conv = nn.Conv3d
309 self.proj = conv(
310 dim_in,
311 dim_out,
312 kernel_size=kernel,
313 stride=stride,
314 padding=padding,
315 )
316
317 def forward(self, x):
318 x = self.proj(x)
319 # B C (T) H W -> B (T)HW C
320 return x.flatten(2).transpose(1, 2)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected