MCPcopy Create free account
hub / github.com/dek924/PerX2CT / Downsample

Class Downsample

taming/modules/diffusionmodules/model.py:56–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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