Combining two tensors

Let say I have:

x = torch.randn(256,384)
y = torch.randn(256, 384)

Can you tell me how to get a variable z with a size of [2, 256, 384]?

torch.stack should work:

x = torch.randn(256,384)
y = torch.randn(256, 384)
z = torch.stack((x, y))
1 Like