How can I stack tensors like this?

I’m trying to stack tensors with different size. But only dimension 2 is different while other dimensions are all same. Is there any way to do this?

torch.cat should work:

a = torch.randn(5, 5, 1)
b = torch.randn(5, 5, 4)
c = torch.cat((a, b), dim=2)
print(c.shape)
> torch.Size([5, 5, 5])

thanks bro, you saved me :joy: :joy: