Return activations for all the layers

Hello,

Given the following code:

def forward(self, x):
    x = x.transpose(2,1)
    x = self.max_pool(x)
    x = x.view(x.size(0), -1)
    x = self.classifier(x)

Does exist an elegant way to get back the results of each layer? Or I should use a dictionary containing a key for each layer result?

Thank you

Hi @lcelona,

This post might be useful How to extract features of an image from a trained model