latest (dev)
Copy
Latest development documentation · Updated 2026-10-15
tensorplay.functional.reshape
- tensorplay.functional.reshape(input, shape) Tensor[source]
Returns a tensor with the same data and number of elements as
input, but with the specified shape. When possible, the returned tensor will be a view ofinput. Otherwise, it will be a copy. Contiguous inputs and inputs with compatible strides can be reshaped without copying, but you should not depend on the copying vs. viewing behavior.See
tensorplay.Tensor.view()on when it is possible to return a view.A single dimension may be -1, in which case it’s inferred from the remaining dimensions and the number of elements in
input.Example:
>>> a = tensorplay.arange(4.) >>> tensorplay.reshape(a, (2, 2)) tensor([[ 0., 1.], [ 2., 3.]]) >>> b = tensorplay.tensor([[0, 1], [2, 3]]) >>> tensorplay.reshape(b, (-1,)) tensor([ 0, 1, 2, 3])
Help improve this page
Found an error, an unclear step, or a missing example?
Was this page helpful?

