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?

2

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).

3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy