Hi guys, I have the following issue. I have three different tensors of size [2, 400, 1, 1], [2, 400, 2, 2] and [2, 400, 4, 4]
. I am trying to find a way to concatenate them together. I know that torch.cat()
function needs same tensor dimensions, but is there away to come up with the final tensor of size [2, 8400]
? If I had 1 instead of 2 batches, I could use view(dim0, -1)
, and then concatenate, but now I do not see any obvious way… Thank you!
Maybe it is a little late. It is possible to achieve this, For example:
x = torch.rand(2, 400, 1, 1)
y = torch.rand(2, 400, 2, 2)
z = torch.rand(2, 400, 4, 4)
x = x.view(x.size(0), -1)
y = y.view(y.size(0), -1)
z = z.view(z.size(0), -1)
out = torch.cat([x, y, z], dim=1)
out
's size will be [2, 8400], hope it can help you.