flâneur — a map of the web's best reading

Tensors — PyTorch Tutorials 1.12.1+cu102 documentation

pytorch.org · 1,232 words · saved by 1 readers

Tensors are a specialized data structure that are very similar to arrays and matrices. In PyTorch, we use tensors to encode the inputs and outputs of a model, as well as the model’s parameters. Tensors are similar to NumPy’s ndarrays, except that tensors can run on GPUs or other specialized hardware to accelerate computing. If you’re familiar with ndarrays, you’ll be right at home with the Tensor API. If not, follow along in this quick API walkthrough. Tensors can be initialized in various ways. Take a look at the following examples: Directly from data Tensors can be created directly from data. The data type is automatically inferred. From a NumPy array Tensors can be created from NumPy arrays (and vice versa - see Bridge with NumPy). From another tensor: The new tensor retains the properties (shape, datatype) of the argument tensor, unless explicitly overridden. With random or constant values: shape is a tuple of tensor dimensions. In the functions below, it determines the dimensional

Note Go to the end to download the full example code. Tensors # Created On: Mar 24, 2017 | Last Updated: May 12, 2026 | Last Verified: Nov 05, 2024 Tensors are a specialized data structure that are very similar to arrays and matrices. In PyTorch, we use tensors to encode the inputs and outputs of a model, as well as the model’s parameters. Tensors are similar to NumPy’s ndarrays, except that tensors can run on GPUs or other specialized hardware to accelerate computing. If you’re familiar with ndarrays, you’ll be right at home with the Tensor API. If not, follow along in this quick API walkthro

Explore this link on the map →

saved by

related reading