| 474 | |
| 475 | class DownSample3D(nn.Module): |
| 476 | def __init__(self, in_channels, with_conv, compress_time=False, out_channels=None): |
| 477 | super().__init__() |
| 478 | self.with_conv = with_conv |
| 479 | if out_channels is None: |
| 480 | out_channels = in_channels |
| 481 | if self.with_conv: |
| 482 | # no asymmetric padding in torch conv, must do it ourselves |
| 483 | self.conv = torch.nn.Conv2d(in_channels, out_channels, kernel_size=3, stride=2, padding=0) |
| 484 | self.compress_time = compress_time |
| 485 | |
| 486 | def forward(self, x): |
| 487 | if self.compress_time and x.shape[2] > 1: |