Transfer learning using VGGFace2 Model in Pytorch

I want to extract features from last layer of VGGFace 2 model (Senet50_256). The last layer is a convolution layer of shape -1,256,1,1. How do I flatten this layer for transfer learning? I got the model from the VGGFace 2 Github https://github.com/ox-vgg/vgg_face2 along with the weights.
Also I am freezing the weights of the model and I only want to optimize the layer which I will add.
Also am I using correct model and weights?

In your auxillary model that you add to the VGG19 pretrained model. You should add these layers at the start.

import torch
batch_size = 16
input = torch.randn(batch_size,256,1,1)
input = input.squeeze(3).squeeze(2).view(-1)

Hi,
Why are you using torch.randn? I am relatively new to pytorch.
Also these are the last layers of the pretrained model

and the layer that I want to add is senetmodel.fc=nn.Linear(256, 128)

But I think before adding this layer I should flatten the feat_extract(Conv2d-238) layer which I am unable to do.

torch.randn was used just to show a dummy input. Ignore it in your code.
input = input.squeeze(3).squeeze(2) --> Use this alone as the starting line for your auxillary model.

My code is working now. Thank you