When we are constructing the network module, how can we determine the input size for fully connected layer after CNN blocks? Should we manually compute the final size after CNN blocks?
For example, for this network module, after layer1 & layer2, we feed the result to fc layer, but why the fc layer input size is
7 * 7 * 32? Is the
7x7 deduced from the formula as described in http://cs231n.github.io/convolutional-networks/?
What I am confused is that this process might be tedious if the network goes deep. Why this can not be deduced automatically?
if you don’t want to calculate, you can do this experimentally by printing out the size of the tensor you want to feed to the
Linear, do a test run and then do it again.
More philosophically, pytorch does not ask you to specify the input size. You pay for the liberty to pass any size items to your conv layers by not having pytorch tell you the output size. What you save is the bureaucracy between you and the actual calculation that intermediate frameworks bring with them to make this easier.
Thanks for your answer~ Really helped me a lot.