Torch: how to concatenate tensors of different sizes?
I have two tensors:
rc of size: torch.Size([128, 16, 1])
xt of size: torch.Size([128, 40, 1])

I would like to concatenate xt to rc along dimension 2 so that the final size of rc_xt is:
rc_xt = torch.Size([128, 40, 2])

In short, I want to 'increase' the size of rc's dimension 1 (16) to 40 -- through any means, even just repeating elements -- and then concatenate them both along dimension 2.
I have tried to google how to do this but I cannot get it working no matter what I do, I'm a little confused about how to go about doing this.
Thank you in advance.

&quot;Increasing&quot; the size of rc can be done simply by padding.
For instance, you can pad it by zeros:
p_rc = nnf.pad(rc, (0, 0, 0, xt.shape[1]-rc.shape[1], 0, 0), 'constant', 0)

Once you have a padded version of rc you can concat:
rc_xt = torch.concat((p_rc, xt), dim=-1)

