The first Linear layer in vgg is defined as nn.Linear(512 * 7 * 7, 4096): if your input image is 240x240, after “feature process”, the output can be view as 512*7*7. But if your input is 480x640，the output of “feature process” is not 512*7*7，so there is the error of mismatch.
You can see more detail in the vgg 240