title: Resize PyTorch Tensor
body: <p>I am currently using the tensor.resize() function to resize a tensor to a new shape <code>t = t.resize(1, 2, 3)</code>.</p>
  
  <p>This gives me a deprecation warning:</p>
  
  <blockquote>
    <p>non-inplace resize is deprecated</p>
  </blockquote>
  
  <p>Hence, I wanted to switch over to the <code>tensor.resize_()</code> function, which seems to be the appropriate in-place replacement. However, this leaves me with an</p>
  
  <blockquote>
    <p>cannot resize variables that require grad</p>
  </blockquote>
  
  <p>error.
  I can fall back to</p>
  
  <pre><code>from torch.autograd._functions import Resize
  Resize.apply(t, (1, 2, 3))
  </code></pre>
  
  <p>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 <code>tensor.resize_()</code> in this case?</p>