I have a tensor with dimensions (30, 35, 49). I want to reshape it to (30, 35, 512) in order to be able to multiply with another tensor which has also
(30, 35, 49)
(30, 35, 512)
A module that might be clearer and more suitable for this question is torch.nn.ConstantPad1d e.g.
torch.nn.ConstantPad1d
import torch from torch import nn x = torch.ones(30, 35, 49) padded = nn.ConstantPad1d((0, 512 - 49), 0)(x)