MCPcopy Create free account
hub / github.com/LTH14/mar / Downsample

Class Downsample

models/vae.py:35–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33
34
35class Downsample(nn.Module):
36 def __init__(self, in_channels, with_conv):
37 super().__init__()
38 self.with_conv = with_conv
39 if self.with_conv:
40 # no asymmetric padding in torch conv, must do it ourselves
41 self.conv = torch.nn.Conv2d(
42 in_channels, in_channels, kernel_size=3, stride=2, padding=0
43 )
44
45 def forward(self, x):
46 if self.with_conv:
47 pad = (0, 1, 0, 1)
48 x = torch.nn.functional.pad(x, pad, mode="constant", value=0)
49 x = self.conv(x)
50 else:
51 x = torch.nn.functional.avg_pool2d(x, kernel_size=2, stride=2)
52 return x
53
54
55class ResnetBlock(nn.Module):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected