Feature matching gradients

Hello there,

I have a sequential model, where I would like to output the features from a given convolutional layer. However, my code is not working properly and I’m not sure whether I can backpropagate the way I implemented this function. pytorch_forum

So, I’m trying to match embeddings as in the image below. However, I’m not sure if this implementation would work. Can you please help me out.

Thanks in advance!