Suppose that I have a tensor of shape
tensor1 = [sentence length, batch_size, embedding dimension]

for instance: torch.Size([4, 32, 768])
I want to add a value to the embedding dimension (768 -> 769).
res = torch.cat((embedding[-1,:,:], batch.feat.unsqueeze(1)), dim=1)

Where, batch.feat is of size [32,1]
but this leads to:
>>> res.size() 
torch.Size([32, 769])

How can I keep the sentence length dimension and have a tensor of shape?
torch.Size([4,32, 769])

(I have posted a related question on this but what I wanted to do didn’t make sense in that case).