I have an idea, and I was wondering if anyone could point me in the right direction. I’d like to:

Run an image through the CNN, keeping the activations at each layer.
For every pixel, collect every filter activation that was influenced by that pixel.
The final result would be a tensor of shape [image height, image width, # of filter channels in the entire network].

I was going to use network.modules() to get a list, and then find all the instances of Conv2d and MaxPool2d (etc.), and go from there… but squeezenet, for example, doesn’t appear to just apply things in the order I get from modules(). Is there some way I can traverse the computation graph, even though it is dynamic? I can figure out how to do it manually, but I’d like to implement a general-purpose function that takes in an arbitrary network.