Jokermania
Jokermania

Reputation: 97

Add new elements to Pytorch tensor

I have a tensor that looks like this: enter image description here

I would like to add 0 to each inner tensor. So we have something like[0.1111, 0.6667, 0]. Any suggestion would be appreciated.

Upvotes: 5

Views: 15321

Answers (1)

Nathan
Nathan

Reputation: 86

You can do :

z = torch.zeros((10,1))
torch.cat((your_tensor,z),1)

Upvotes: 4

Related Questions