Extracting Features from my pretrained CNN, not from Model Zoo


I have trained my CNN model on dataset and now want to extract feature from query image from FC layer. How can I do that?


You could register a forward hook to the layer you would like to get the activations from.
Have a look at this example.

Another approach would be to modify the forward method and return the desired activation.

1 Like

Thank you @ptrblck. The second approach is much easier :slight_smile:

1 Like