Does someone know how to extract outputs at specific locations? For example, I would like to get all outputs corresponding to convolution layers, including the hidden one under sequential. Any idea?
Thanks
You could use forward hooks to get the intermediate activations from your model as described here. Let me know, if this would work for you or if I misunderstood the question.
Thanks a lot
What if part of the layers are built in sequential? I am using the resnet18 pre-trained model of pytorch, how to call those layers?
You can index modules inside an nn.Sequential
container via indexing:
model = nn.Sequential(
nn.Conv2d(3, 6, 3, 1, 1),
nn.ReLU(),
nn.Conv2d(6, 1, 3, 1, 1)
)
print(model[2]) # index second conv layer