Tensors — PyTorch Tutorials 1.12.1+cu102 documentation
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
- Tensors — PyTorch Tutorials 2.13.0+cu130 documentationdocs.pytorch.org
- PyTorch internals : ezyang's blogblog.ezyang.com
- torch.Tensor — PyTorch 2.12 documentationdocs.pytorch.org
- PyTorch (@PyTorch) / Xx.com
- Learning PyTorch with Examples — PyTorch Tutorials 2.12.0+cu130 documentationpytorch.org
- Tiny TPUtinytpu.com
- The Tensor: The fundamental data structure of ML - DEV Communitydev.to
- Chapter 0: Fundamentals - ARENAlearn.arena.education
- PiTorch: ML on Baremetal Raspberry Pis | projectsmasonjwang.com
- the bug that taught me more about PyTorch than years of using it | Elana Simonelanapearl.github.io
- 2404.17625arxiv.org
- Einops: Powerful library for tensor operations in deep learning | Oxford Protein Informatics Groupblopig.com