when you load the model,
model = models.resnet18(pretrained=True)
and print it, you see AdaptiveAvgPool2d layer followed by a linear layer, at the end of the architecture.
I dont understand how is it working without flattening the output of the AdaptiveAvgPool2d  layer.
how do i use a linear layer after the AdaptiveAvgPool2d layer?
Consider this example:
m = nn.AdaptiveAvgPool2d((5,7))
dense = nn.Linear(5, 10)
input = torch.randn(1, 64, 8, 9)
output = m2(input) # its shape should be (1, 64, 5, 7)
output2 = dense(output) # this line throws an error.
Please help me with this. Thanks in advance !