128 def __init__(self, last_stride, bn_norm, with_ibn, with_se, with_nl, block, layers, non_layers):
129 self.inplanes = 64
130 super().__init__()
131 self.conv1 = nn.Conv2d(3, 64, kernel_size=7, stride=2, padding=3,
132 bias=False)
133 self.bn1 = get_norm(bn_norm, 64)
134 self.relu = nn.ReLU(inplace=True)
135 self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1)
136
137 self.layer1 = self._make_layer(block, 64, layers[0], 1, bn_norm, with_ibn, with_se)
138 self.layer2 = self._make_layer(block, 128, layers[1], 2, bn_norm, with_ibn, with_se)
139 self.layer3 = self._make_layer(block, 256, layers[2], 2, bn_norm, with_ibn, with_se)
140 self.layer4 = self._make_layer(block, 512, layers[3], last_stride, bn_norm, with_se=with_se)
141
142 self.random_init()
143
144
145 if with_nl: self._build_nonlocal(layers, non_layers, bn_norm)
146 else: self.NL_1_idx = self.NL_2_idx = self.NL_3_idx = self.NL_4_idx = []
147
148