Reputation: 11
I have a problem while working on PyTorch.
I'm trying to increase tensor size from [1,97,1]
to [1,97,2]
. How can I add "1" in tensor size?
Upvotes: 0
Views: 77
Reputation: 7723
Use pad
import torch.nn.functional as F
a = torch.empty((1,97,1))
a = F.pad(input=a, pad=(0,1)) # pad = (padding_left,padding_right)
print(a.shape)
>>> torch.Size([1, 97, 2])
it will pad 0
constant by default at right sight.
Upvotes: 1