MCPcopy Create free account
hub / github.com/CompVis/diff2flow / __init__

Method __init__

diff2flow/kl_autoencoder.py:122–150  ·  view source on GitHub ↗
(self, *, in_channels, out_channels=None, conv_shortcut=False,
                 dropout, temb_channels=512)

Source from the content-addressed store, hash-verified

120
121class ResnetBlock(nn.Module):
122 def __init__(self, *, in_channels, out_channels=None, conv_shortcut=False,
123 dropout, temb_channels=512):
124 super().__init__()
125 self.in_channels = in_channels
126 out_channels = in_channels if out_channels is None else out_channels
127 self.out_channels = out_channels
128 self.use_conv_shortcut = conv_shortcut
129
130 self.norm1 = Normalize(in_channels)
131 self.conv1 = nn.Conv2d(in_channels, out_channels, kernel_size=3, stride=1, padding=1)
132
133 if temb_channels > 0:
134 self.temb_proj = nn.Linear(temb_channels, out_channels)
135 self.norm2 = Normalize(out_channels)
136 self.dropout = nn.Dropout(dropout)
137 self.conv2 = nn.Conv2d(out_channels, out_channels, kernel_size=3, stride=1, padding=1)
138 if self.in_channels != self.out_channels:
139 if self.use_conv_shortcut:
140 self.conv_shortcut = nn.Conv2d(in_channels,
141 out_channels,
142 kernel_size=3,
143 stride=1,
144 padding=1)
145 else:
146 self.nin_shortcut = nn.Conv2d(in_channels,
147 out_channels,
148 kernel_size=1,
149 stride=1,
150 padding=0)
151
152 def forward(self, x, temb=None):
153 h = x

Callers

nothing calls this directly

Calls 2

NormalizeFunction · 0.70
__init__Method · 0.45

Tested by

no test coverage detected