pytorch-seq2seq icon indicating copy to clipboard operation
pytorch-seq2seq copied to clipboard

How to matrix multiply two encoded representations?

Open jlim13 opened this issue 5 years ago • 1 comments

Lets say I have two encoders and they produce representations A and B. They are both of shape batch x seq len x hid dim. I want to combine these features. Is there a way to do a matrix multiplication such that my output is batch x seq len x hid dim. I am not sure there is. At the moment, I am just doing elementwise multiplication or addition

jlim13 avatar Aug 15 '20 18:08 jlim13

You can do what is done in the MultiHeadAttentionLayer and split the hid_dim into multiple "heads", but as it stands you have to do elementwise operations.

What are you trying to do? Some sort of attention mechanism?

bentrevett avatar Aug 25 '20 16:08 bentrevett