MCPcopy Create free account
hub / github.com/AlayaLab/Hive / Downsample

Class Downsample

models/flowsep/latent_diffusion/modules/diffusionmodules/model.py:76–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74
75
76class Downsample(nn.Module):
77 def __init__(self, in_channels, with_conv):
78 super().__init__()
79 self.with_conv = with_conv
80 if self.with_conv:
81 # Do time downsampling here
82 # no asymmetric padding in torch conv, must do it ourselves
83 self.conv = torch.nn.Conv2d(
84 in_channels, in_channels, kernel_size=3, stride=2, padding=0
85 )
86
87 def forward(self, x):
88 if self.with_conv:
89 pad = (0, 1, 0, 1)
90 x = torch.nn.functional.pad(x, pad, mode="constant", value=0)
91 x = self.conv(x)
92 else:
93 x = torch.nn.functional.avg_pool2d(x, kernel_size=2, stride=2)
94 return x
95
96
97class DownsampleTimeStride4(nn.Module):

Callers 3

__init__Method · 0.70
__init__Method · 0.70
__init__Method · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected