MCPcopy Create free account
hub / github.com/OpenTalker/StyleHEAT / FirstBlock2d

Class FirstBlock2d

models/styleheat/base_function.py:290–307  ·  view source on GitHub ↗

Downsampling block for use in encoder.

Source from the content-addressed store, hash-verified

288
289
290class FirstBlock2d(nn.Module):
291 """
292 Downsampling block for use in encoder.
293 """
294
295 def __init__(self, input_nc, output_nc, norm_layer=nn.BatchNorm2d, nonlinearity=nn.LeakyReLU(), use_spect=False):
296 super(FirstBlock2d, self).__init__()
297 kwargs = {'kernel_size': 7, 'stride': 1, 'padding': 3}
298 conv = spectral_norm(nn.Conv2d(input_nc, output_nc, **kwargs), use_spect)
299
300 if type(norm_layer) == type(None):
301 self.model = nn.Sequential(conv, nonlinearity)
302 else:
303 self.model = nn.Sequential(conv, norm_layer(output_nc), nonlinearity)
304
305 def forward(self, x):
306 out = self.model(x)
307 return out
308
309
310class DownBlock2d(nn.Module):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected