Batch Wise Expand


I am new to pytorch.

I am trying to perform sij = Wq([wi ; wj]) where wi and wj are the word embeddings and trying to concatenate every word with other words in a sentence. I thought of doing it by repeating the word embeddings using the expand() as described here Expand a 2d tensor to 3d tensor. But the issue is my output is 3D tensor batch, len, dimension so I am not sure if I should make them 4D tensor.

Please help.