Tensors | PyTorch Tutorials

Tensors

Initialize a Tensor

Direct from Data

From NumPy array

From another tensor

With random or constant values

shape is a tuple of tensor dimensions. This determines the dimensionality of the output tensor.


Attributes of a Tensor


Operations on Tensors

Tensor Operations Docs

NumPy-like indexing & slicing

Join Tensors

Arithmetic

Single-element Tensors

In-place Operations

This is discouraged because with derivatives, the history will be lost automatically.

Bridge with NumPy

Tensor to NumPy array

NumPy array to Tensor