Can't understand the output shape of Identity layer while using it to replace Fully Connected layer

I’m computing the Frechet Inception Distance(FID) with Inception-v3 Network.

And I try to replace the Fully Connected layer with Identity layer to extract the features.

Before implementing the replacement inception_model.fc = torch.nn.Identity(), check the model summary and get the output shape of last two layers as below:

  • InceptionE-293 [-1, 2048, 8, 8]
  • Linear-294 [-1, 1000]

After implementing the replacement, check and get the output shape of last two layers as below:

  • InceptionE-293 [-1, 2048, 8, 8]
  • Identity-294 [-1, 2048]

The confusion is:
why the output shape of Identity layer is [-1, 2048], and not the same as its input, which is [-1, 2048, 8, 8] ?

Thanks~

Hello @Damon_Roux,

Have you looked at the model text description? There might be layers or layers between 293 and 294.

I don’t know exactly which implementation of InceptionV3 do you use but it is highly likely that there might be AvgPool2d or some other pooling layer between InceptionE-293 and Linear-294. Pooling layer reduces the dimensionality in the first case when the tensor passed to a fully connected layer and in the second case when it’s passed to identity layer.