How do I get intermediate layer activations during prediction time.
I believe it can be done it two ways :-
1) Build the network upto the layer you want
2) Register hooks/callbacks
My use case is that I want activations from the pre final layer of a pretrained resnet 18. I want the activations before the relu activation is applied such that I get 512 activations.
How do I construct this network using 1)?
I tried doing this but I’m not sure how to construct it in a way that gets me activations before the relu non-linearity is applied .
feature_extractor = cnn_learner(data, models.resnet18, metrics=[accuracy]) model = feature_extractor.model feature_extractor.model = nn.Sequential((list(model.children())[:-1]))
- I’m unsure how to register hooks during prediction time and get access to them.
Could you please help me out with this?