Not able to view the forward method of a pretrained model

Hi ,

I loaded a pretrained shuffle-net-v2 model from torch.hub . I am able to perfrom inference on it . However I am not able to access the forward method implemented in it. I need to access the forward method since I want to print the intermediate activations of each layer and also to know exact operation performed ( in the sense that when I see the model description, it does not show where the residual connections are and so on …)

Any help in this regard would be greatly appreciated.

Thankyou in advance .

I dont know if I understood you very well but I think that you need to add this kind of thing in your model’s definition since the begining like for example.
in the forward function, put each output of each layer inside a list and then return the whole vector after that and therefore you’d be able to access any output of any layer.
This worked for me before.

Yes … I was able to do that when I trained my own model from scratch i.e I was printing the activations after each layer from within the forward method . But when I take pre-trained model from the hub, how do I do it ?

As far as I know, I am not sure so I can be wrong. I think that in this case you won’t be able to do it

Thanks for the quick reply !!