Get a 128 dim feature vector from a pretrained model without fine tuning in Pytorch
I need visual features from a set of images in order to have a kind of embedding of a input image. The dimension I need is 128.
I thought of removing the last layer of a pretrained model such as ResNet50, than replace the last fully connected layer with a flatten layer and do a forward pass for each image. The issue is that after the flatten layer ResNet50 gives you a 512 dim feature vector. If I add another fully connected layer with output dim of 128 I need to retrain and fine tuning the network since I'm adding new parameters.
Is there any way to get a 128 dim feature vector from the last layer of 512 dim feature vector without adding learnable parameters?

You could apply a Principal Component Analysis (PCA) on your features retrieved from the pre-trained model to reduce the dimensionality to 128 components.
