Concat Two Tensors
I Want to Concat Two Tensors of Size a: Torch. Size([16, 1]) and B: Torch. Size([16, 120]) to Be of Size Torch. Size([16, 121]) Could You Please Help with...
I want to concat two tensors of size a: torch.Size([16, 1]) and b: torch.Size([16, 120])
to be of size torch.Size([16, 121])
could you please help with that?
1 Answer
Here you can use the torch.cat() function.
Example:
>>> a = torch.rand([16,1])
>>> b = torch.rand([16,120])
>>> a.size()
torch.Size([16, 1])
>>> b.size()
torch.Size([16, 120])
>>> c = torch.cat((a,b),dim=1)
>>> c.size()
torch.Size([16, 121])
What you want to do is to concatenate the tensors on the first dimension (dim=1).