MCPcopy Create free account
hub / github.com/JunlinHan/DCLGAN / __init__

Method __init__

models/networks.py:1102–1144  ·  view source on GitHub ↗

Construct a Resnet-based encoder Parameters: input_nc (int) -- the number of channels in input images output_nc (int) -- the number of channels in output images ngf (int) -- the number of filters in the last conv layer norm_

(self, input_nc, output_nc, ngf=64, norm_layer=nn.BatchNorm2d, use_dropout=False, n_blocks=6, padding_type='reflect', no_antialias=False)

Source from the content-addressed store, hash-verified

1100 """
1101
1102 def __init__(self, input_nc, output_nc, ngf=64, norm_layer=nn.BatchNorm2d, use_dropout=False, n_blocks=6, padding_type='reflect', no_antialias=False):
1103 """Construct a Resnet-based encoder
1104
1105 Parameters:
1106 input_nc (int) -- the number of channels in input images
1107 output_nc (int) -- the number of channels in output images
1108 ngf (int) -- the number of filters in the last conv layer
1109 norm_layer -- normalization layer
1110 use_dropout (bool) -- if use dropout layers
1111 n_blocks (int) -- the number of ResNet blocks
1112 padding_type (str) -- the name of padding layer in conv layers: reflect | replicate | zero
1113 """
1114 assert(n_blocks >= 0)
1115 super(ResnetEncoder, self).__init__()
1116 if type(norm_layer) == functools.partial:
1117 use_bias = norm_layer.func == nn.InstanceNorm2d
1118 else:
1119 use_bias = norm_layer == nn.InstanceNorm2d
1120
1121 model = [nn.ReflectionPad2d(3),
1122 nn.Conv2d(input_nc, ngf, kernel_size=7, padding=0, bias=use_bias),
1123 norm_layer(ngf),
1124 nn.ReLU(True)]
1125
1126 n_downsampling = 2
1127 for i in range(n_downsampling): # add downsampling layers
1128 mult = 2 ** i
1129 if(no_antialias):
1130 model += [nn.Conv2d(ngf * mult, ngf * mult * 2, kernel_size=3, stride=2, padding=1, bias=use_bias),
1131 norm_layer(ngf * mult * 2),
1132 nn.ReLU(True)]
1133 else:
1134 model += [nn.Conv2d(ngf * mult, ngf * mult * 2, kernel_size=3, stride=1, padding=1, bias=use_bias),
1135 norm_layer(ngf * mult * 2),
1136 nn.ReLU(True),
1137 Downsample(ngf * mult * 2)]
1138
1139 mult = 2 ** n_downsampling
1140 for i in range(n_blocks): # add ResNet blocks
1141
1142 model += [ResnetBlock(ngf * mult, padding_type=padding_type, norm_layer=norm_layer, use_dropout=use_dropout, use_bias=use_bias)]
1143
1144 self.model = nn.Sequential(*model)
1145
1146 def forward(self, input):
1147 """Standard forward"""

Callers

nothing calls this directly

Calls 4

norm_layerFunction · 0.85
ResnetBlockClass · 0.85
DownsampleClass · 0.70
__init__Method · 0.45

Tested by

no test coverage detected