I am currently using the tensor.resize() function to resize a tensor to a new shape t = t.resize(1, 2, 3)
.
This gives me a deprecation warning:
non-inplace resize is deprecated
Hence, I wanted to switch over to the tensor.resize_()
function, which seems to be the appropriate in-place replacement. However, this leaves me with an
cannot resize variables that require grad
error. I can fall back to
from torch.autograd._functions import Resize
Resize.apply(t, (1, 2, 3))
which is what tensor.resize() does in order to avoid the deprecation warning.
This doesn't seem like an appropriate solution but rather a hack to me.
How do I correctly make use of tensor.resize_()
in this case?