PyTorch - Best way to get at intermediate layers in VGG and ResNet?

with fast ai, there are many ways to get the intermediate layers without using register the hook-like plain python. For Resent, I have used more than one method, one of the methods flattens the layer and extract the output by index.

In addition, for VGG, it is, even more, simpler if you want to extract the batch norm layers. The example is in this notebook.

1 Like