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
The simplest solution is to allocate a tensor with your padding value and the target dimensions and assign the portion for which you have data:
target = torch.zeros(30, 35, 512)
source = torch.ones(30, 35, 49)
target[:, :, :49] = source
Note that there is no guarantee that padding your tensor with zeros and then multiplying it with another tensor makes sense in the end, that is up to you.