How can I extract the feature vector of the last hidden layer of the Alex net in pytorch?
I’ve trained an Alex net in pytorch and I want to extract feature vectors from the layers
What is the function which I should use?

In my opinion, you can define a function in the model class which takes input and output the features you like, for example:

class model(nn.Module):
    def __init__(self):
        # init codes
    def forward(self, input):
        # forward codes
    def yourfunc(self, input):
        # codes
        #return feature1, feature2


This yourfunc only takes your input and outputs features you need, it does no backward computation. You just need to call it wherever you need. And I don't think there are built-in functions in PyTorch can do that since it is easy to implement by yourself.
