self.nf = num_features(layers)*2
in ConvnetBuilder class of fastai self.nf is evaluated to 512*2 = 1024. self.nf is then passed as num_features to nn.BatchNorm1d.
How can BatchNorm1d accept 1024 features when the layer prior to that (8th layer of resnet34) outputs 512 features.
I guess it’s due to the AdaptiveConcatPool2d.
self.ap = nn.AdaptiveAvgPool2d(sz)
self.mp = nn.AdaptiveMaxPool2d(sz)
def forward(self, x): return torch.cat([self.mp(x), self.ap(x)], 1)
Ah ok, I see that the above code will result in output becoming twice the input because there is column wise concatenation of features.
Thanks for pointing me to the docs link.