Skip to content
masterclass Buddy

PyTorch · Function

torch.reshape

torch.reshape changes a tensor to a requested shape while keeping its data and number of elements. It may return a view or a copy, so code should not depend on which one occurs.

Last updated

Syntax

torch.reshape(input, shape) → Tensor

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • torch.Tensor.view()
  • torch.Tensor.reshape()

Source: torch.reshape — PyTorch 2.14 documentation. Checked 2026-11-03.