MCPcopy
hub / github.com/ermongroup/ddim / Downsample

Class Downsample

models/diffusion.py:55–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53
54
55class Downsample(nn.Module):
56 def __init__(self, in_channels, with_conv):
57 super().__init__()
58 self.with_conv = with_conv
59 if self.with_conv:
60 # no asymmetric padding in torch conv, must do it ourselves
61 self.conv = torch.nn.Conv2d(in_channels,
62 in_channels,
63 kernel_size=3,
64 stride=2,
65 padding=0)
66
67 def forward(self, x):
68 if self.with_conv:
69 pad = (0, 1, 0, 1)
70 x = torch.nn.functional.pad(x, pad, mode="constant", value=0)
71 x = self.conv(x)
72 else:
73 x = torch.nn.functional.avg_pool2d(x, kernel_size=2, stride=2)
74 return x
75
76
77class ResnetBlock(nn.Module):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected