torch.Tensor.expand — PyTorch 2.7 documentation
Tensor can be also expanded to a larger number of dimensions, and the new ones will be appended at the front. For the new dimensions, the size cannot be set to -1. Expanding a tensor does not allocate new memory, but only creates a new view on the existing tensor where a dimension of size one is expanded to a larger size by setting the stride to 0. Any dimension of size 1 can be expanded to an arbitrary value without allocating new memory. *sizes (torch.Size or int...) – the desired expanded size WARNING More than one element of an expanded tensor may refer to a single memory location. As a result, in-place operations (especially ones that are vectorized) may result in incorrect behavior. If you need to write to the tensors, please clone them first. Example: © Copyright PyTorch Contributors. Access comprehensive developer documentation for PyTorch Get in-depth tutorials for beginners and advanced developers Find development resources and get your questions answered © Copyright The Linu
Redirecting… Continue to ../../2.13/generated/torch.Tensor.expand.html
Explore this link on the map →related reading
- torch.reshape — PyTorch 2.12 documentationdocs.pytorch.org
- PyTorch internals : ezyang's blogblog.ezyang.com
- torch.Tensor — PyTorch 2.12 documentationdocs.pytorch.org
- torch.stack — PyTorch 2.12 documentationdocs.pytorch.org
- torch.ones_like — PyTorch 2.12 documentationdocs.pytorch.org
- Tensors — PyTorch Tutorials 2.12.0+cu130 documentationpytorch.org
- torch.empty — PyTorch 2.12 documentationdocs.pytorch.org
- Chapter 0: Fundamentals - ARENAlearn.arena.education
- torch.zeros_like — PyTorch 2.12 documentationdocs.pytorch.org
- torch.index_select — PyTorch 2.12 documentationdocs.pytorch.org
- Tensors — PyTorch Tutorials 2.13.0+cu130 documentationdocs.pytorch.org
- Einops: Powerful library for tensor operations in deep learning | Oxford Protein Informatics Groupblopig.com