I have a tensor of size (64L, 3L, 7L, 7L) and I want to expand it to a size of (64L, 4L, 7L, 7L). I tried using ‘expand’ method but it doesn’t work for non-singleton dimensions. I am new to PyTorch, any help is appreciated. Thank you.
Hi
What do you want to extra dimension to contain?
The original tensor contains float values and I want the additional space in 2nd dimension to contain float values as well.
I guess the simplest solution is just to concatenate a new tensor to it:
out = torch.cat([input, torch.zeros(64, 1, 7, 7)], 1)
Thanks a lot for the quick reply!