There might be utility functions in the wild, but I would recommend to use a dummy input tensor, print all necessary activation shapes, and set the input features of linear layers in this way.
Since each forward pass is dynamic in PyTorch and the computation graph will be created during the forward pass, the shape inference is not straightforward to calculate in eager mode.


Yes, the activation will be flattened to [batch_size, 4*4*64]. I would generally recommend to use x.view(x.size(0), -1) to keep the batch size and run into shape mismatch errors instead of changing the batch size, which would be harder to debug.


That might be expected, as a pretrained ResNet is quite powerful for a variety of tasks.