MCPcopy Create free account
hub / github.com/chenhaoxing/HDNet / __init__

Method __init__

models/networks.py:341–400  ·  view source on GitHub ↗

Construct a Unet submodule with skip connections. Parameters: outer_nc (int) -- the number of filters in the outer conv layer inner_nc (int) -- the number of filters in the inner conv layer input_nc (int) -- the number of channels in input images/features

(self, outer_nc, inner_nc, input_nc=None, submodule=None, outermost=False, innermost=False,
                 norm_layer=RAIN, use_dropout=False, use_attention=False, enc=True, dec=True)

Source from the content-addressed store, hash-verified

339 |-- downsampling -- |submodule| -- upsampling --|
340 """
341 def __init__(self, outer_nc, inner_nc, input_nc=None, submodule=None, outermost=False, innermost=False,
342 norm_layer=RAIN, use_dropout=False, use_attention=False, enc=True, dec=True):
343 """Construct a Unet submodule with skip connections.
344
345 Parameters:
346 outer_nc (int) -- the number of filters in the outer conv layer
347 inner_nc (int) -- the number of filters in the inner conv layer
348 input_nc (int) -- the number of channels in input images/features
349 submodule (UnetBlockCodec) -- previously defined submodules
350 outermost (bool) -- if this module is the outermost module
351 innermost (bool) -- if this module is the innermost module
352 norm_layer -- normalization layer
353 user_dropout (bool) -- if use dropout layers.
354 enc (bool) -- if use give norm_layer in encoder part.
355 dec (bool) -- if use give norm_layer in decoder part.
356 """
357 super(UnetBlockCodec, self).__init__()
358 self.outermost = outermost
359 self.innermost = innermost
360 self.use_dropout = use_dropout
361 self.use_attention = use_attention
362 use_bias = False
363 if input_nc is None:
364 input_nc = outer_nc
365 self.norm_namebuffer = ['RAIN', 'RAIN_Method_Learnable', 'RAIN_Method_BN']
366 if outermost:
367 self.down = nn.Conv2d(input_nc, inner_nc, kernel_size=4, stride=2, padding=1, bias=use_bias)
368 self.submodule = submodule
369 self.up = nn.Sequential(
370 nn.ReLU(True),
371 nn.ConvTranspose2d(inner_nc * 2, outer_nc, kernel_size=4, stride=2, padding=1),
372 nn.Tanh()
373 )
374 elif innermost:
375 self.up = nn.Sequential(
376 nn.LeakyReLU(0.2, True),
377 nn.Conv2d(input_nc, inner_nc, kernel_size=4, stride=2, padding=1, bias=use_bias),
378 nn.ReLU(True),
379 nn.ConvTranspose2d(inner_nc, outer_nc, kernel_size=4, stride=2, padding=1, bias=use_bias)
380 )
381 self.upnorm = norm_layer(outer_nc) if dec else get_norm_layer('instance')(outer_nc)
382 else:
383 self.down = nn.Sequential(
384 nn.LeakyReLU(0.2, True),
385 nn.Conv2d(input_nc, inner_nc, kernel_size=4, stride=2, padding=1, bias=use_bias),
386 )
387 self.downnorm = norm_layer(inner_nc) if enc else get_norm_layer('instance')(inner_nc)
388 self.submodule = submodule
389 self.up = nn.Sequential(
390 nn.ReLU(True),
391 nn.ConvTranspose2d(inner_nc * 2, outer_nc, kernel_size=4, stride=2, padding=1, bias=use_bias),
392 )
393 self.upnorm = norm_layer(outer_nc) if dec else get_norm_layer('instance')(outer_nc)
394 if use_dropout:
395 self.dropout = nn.Dropout(0.5)
396
397 if use_attention:
398 attention_conv = nn.Conv2d(outer_nc+input_nc, outer_nc+input_nc, kernel_size=1)

Callers

nothing calls this directly

Calls 2

get_norm_layerFunction · 0.85
__init__Method · 0.45

Tested by

no test coverage detected