I tried to delete only the avgpool of the resnet but i got always mismatch errors. To avoid this error I replaced
resnet.avgpool = nn.AvgPool2d(kernel_size=7, stride=1, padding=0)
by
resnet.avgpool = nn.AvgPool2d(kernel_size=1, stride=1, padding=0)
and then
resnet.fc = nn.Linear(512x7x7,number_of_classes).
It is not the optimized way to deal with the problem. Do you have a better solution please?