This is sort of an extended version of the question in Accessing intermediate layers of a pretrained network forward? 2.
Coming from tensorflow (and liking it here, this is a great community!) I am probably just approaching this the wrong way.
I am trying to write a really simple feature extraction script.
Given an input image (or a stack of images) I just want to compute some features using a pretrained vgg19 and dump them into a binary file. No backprop, no bells or whistles, really.
Thing is, which features exactly is a parameter to my script.
Now, in tensorflow, this would essentially be something along the lines of
logits, end_points = vgg19(inputs)
return [end_points[k] for k in targets]

where targets are conv1_1 or fc6 for example.
How do I do something similar in pytorch?
What I have inferred so far would be possible:

create a subclass of nn.Module

inside that module, load vgg19
essentially re-build the entirety of the original vgg19 model using the submodules of the normal vgg19, and adding names to the submodule keys to be able to address them by those names later
define forward() to do the forward pass until the last target, keeping the intermediate results in a list and returning them.

This seems awfully complicated for what I’m trying to achieve, so I’m probably approaching this the wrong way… help, please?