Deep Learning with PyTorch: A 60 Minute Blitz in_features?

Hi everyone,

I just went through the 60min Blitz tutorial and I have a question. How do they reach a value of 16 * 5 * 5 for the first fully connected layer in their network (in the last part of the tutorial)? 16 is the number of out_channels from the conv2 layer but I can’t figure out the 5 * 5. When I use the formula to calculate it starting with a value of 32 * 32 I reach a value of 10 * 10 and not 5 * 5.

Can anyone help me? :slight_smile:

My calculations:

  1. input size (32) - kernel size (5) + 1 = 28
  2. ((28 - kernel size (2)) / 2) + 1 = 14
  3. 14 - kernel size (5) + 1 = 10
    no more layers before the fully connected one so my guess would be 10…

In step 3 you are missing the self.pool operation, which would reduce the spatial size by a factor of 2 and would thus result in an activation of [batch_size, 16, 5, 5]. :wink:

1 Like

Thank you @ptrblck! :slight_smile: