Obtain intermediate outputs from pre-trained models

Given that I have a pre-trained pytorch model, what is the “right” way to obtain several intermediate results of the network?

For example, suppose I obtain an ResNet-50 pre-trained from imagenet. Now, I want to look at the outputs for each named layer of Table 1 of the original paper (https://arxiv.org/pdf/1512.03385.pdf). What is the “right” way to the intermediate results of the 5 blocks for a fixed dataset?

You could use forward hooks as described in this post and register the desired layers using their name.