Forward pass of the PatchEmbed module. Parameters: - x (torch.Tensor): The input tensor of shape (B, C, T, H, W) where B is the batch size, C is the number of channels, T is the temporal dimension, H is the height, and
(self, x: torch.Tensor)
| 832 | torch.nn.init.trunc_normal_(self.proj[1].weight, std=std, a=-3 * std, b=3 * std) |
| 833 | |
| 834 | def forward(self, x: torch.Tensor) -> torch.Tensor: |
| 835 | """ |
| 836 | Forward pass of the PatchEmbed module. |
| 837 | |
| 838 | Parameters: |
| 839 | - x (torch.Tensor): The input tensor of shape (B, C, T, H, W) where |
| 840 | B is the batch size, |
| 841 | C is the number of channels, |
| 842 | T is the temporal dimension, |
| 843 | H is the height, and |
| 844 | W is the width of the input. |
| 845 | |
| 846 | Returns: |
| 847 | - torch.Tensor: The embedded patches as a tensor, with shape b t h w c. |
| 848 | """ |
| 849 | assert x.dim() == 5 |
| 850 | _, _, T, H, W = x.shape |
| 851 | assert ( |
| 852 | H % self.spatial_patch_size == 0 and W % self.spatial_patch_size == 0 |
| 853 | ), f"H,W {(H, W)} should be divisible by spatial_patch_size {self.spatial_patch_size}" |
| 854 | assert T % self.temporal_patch_size == 0 |
| 855 | x = self.proj(x) |
| 856 | return x |
| 857 | |
| 858 | |
| 859 | class FinalLayer(nn.Module): |
nothing calls this directly
no outgoing calls
no test coverage detected