MCPcopy Create free account
hub / github.com/NVIDIA/semantic-segmentation / __init__

Method __init__

network/utils.py:174–205  ·  view source on GitHub ↗
(self, in_dim, reduction_dim=256, output_stride=16,
                 rates=(6, 12, 18))

Source from the content-addressed store, hash-verified

172 """
173
174 def __init__(self, in_dim, reduction_dim=256, output_stride=16,
175 rates=(6, 12, 18)):
176 super(AtrousSpatialPyramidPoolingModule, self).__init__()
177
178 if output_stride == 8:
179 rates = [2 * r for r in rates]
180 elif output_stride == 16:
181 pass
182 else:
183 raise 'output stride of {} not supported'.format(output_stride)
184
185 self.features = []
186 # 1x1
187 self.features.append(
188 nn.Sequential(nn.Conv2d(in_dim, reduction_dim, kernel_size=1,
189 bias=False),
190 Norm2d(reduction_dim), nn.ReLU(inplace=True)))
191 # other rates
192 for r in rates:
193 self.features.append(nn.Sequential(
194 nn.Conv2d(in_dim, reduction_dim, kernel_size=3,
195 dilation=r, padding=r, bias=False),
196 Norm2d(reduction_dim),
197 nn.ReLU(inplace=True)
198 ))
199 self.features = nn.ModuleList(self.features)
200
201 # img level features
202 self.img_pooling = nn.AdaptiveAvgPool2d(1)
203 self.img_conv = nn.Sequential(
204 nn.Conv2d(in_dim, reduction_dim, kernel_size=1, bias=False),
205 Norm2d(reduction_dim), nn.ReLU(inplace=True))
206
207 def forward(self, x):
208 x_size = x.size()

Callers

nothing calls this directly

Calls 2

Norm2dFunction · 0.90
__init__Method · 0.45

Tested by

no test coverage detected