I am trying to visualize the attention maps of my model. There are two pathways that compute attention maps for the visual features (v1 and v2) of two different images, and the features (q) of a question but the attention mechanism is shared. So I have something like this in the forward method of my model:
v1 = self.attention_mechanism(v1, q) v2 = self.attention_mechanism(v2, q)
Because the attention mechanism is shared by both pathways, registering the hook for, say, attention_mechanism.conv2 will give me the attention map for v2. But I need to register it for both v1 and v2. What would be the way to do it? I tried several things but none of them worked.