Forward hook - any way to differentiate by model's input?

Hi there,

I’m using forward hooks to look at the intermediate activations of a net as it goes through, works great.

I’d like to be able to correlate/separate these activations by the input, so I can see just the activations for a particulr input, even if multiple inputs are being processed at the same time or while the hooks are in place. In essence I’d like to be able to separate the data that the hooks give me into something like:

For input #1 → activations #1
input #2 → activations #2

As I understand it now, the hooks give me the activations but won’t tell me for which input they are.

Make sense? Thanks in advance

The activations will have a batch dimension containing containing the activation for each corresponding input. I.e. the activation at batch index i corresponds to input at index i.

Thanks! I’ll check that out for batches.

How about for separate batches? ie: if I run one batch through, then another right after - is there a way to differentiate them in that case?

The forward hooks will be triggered during the forward pass so you should be able to process the intermediate activations between separate forward passes.

thanks, much appreciated!