Skip to content

view

Tensor reshaping as a module wrapping Tensor.view.

Classes:

  • View –

    Returns a new view of the tensor with the same data.

View

View(*shape: int)

Bases: Module

Returns a new view of the tensor with the same data. This is a wrapper around the torch.view function.

Note

This will not create a copy of the tensor and is generally more efficient than a torch.reshape call. However, it requires the input tensor to have a contiguous memory layout.

Parameters:

  • *shape (int, default: () ) –

    The new shape of the tensor.