Solved by Eta_C in post #2 
              
              
                Actually, nn.Linear need a certain in_features, which is CxHxW. Now you can see H and W depend on the input resolution. 
Following the document, AdaptivaAvgPool2d 

Applies a 2D adaptive average pooling over an input signal composed of several input planes. 
The output is of size H x W, for any inpu…