i have two tensors, lets say, x=torch.rand([64,8,1,33325]) and x1= torch.rand([64,1,1,33325]) and i want to get an output of my torch.cat to be output.size([64,8,1,66650]) [batch_size, channels, height, width]. i am trying to do things but cannot get it done. anybody can help?
So you want the tensor x1 to be expanded to 64 x 8 x 1 x 33325, right?
This is a case where broadcasting isn’t automatic, but if you do x1 = x1.expand(-1, 8, -1, -1, -1)
, the torch.cat([x, x1], dim=-1)
should work.
Best regards
Thomas
thank you. works like charm