I have a set of tensors that I'm padding with pad_sequence
but I need to guarantee a fixed length for them. I can't do it right now as pad_sequence
will extend the shorter tensors up to the longest, if that longest tensor doesn't reach the length I want them I'm screwed. I thought a solution could be adding zeros to one of the tensors to padd up to the length I want so the result of that padding will have my desired length. I don't know how to do it
So lets say I have a tensor with shape torch.Size([44])
and a desired length 50, how can I add zeros to it to reach a shape of torch.Size([50])
? This needs to hold regardless of the initial tensor shape.