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

torch.Tensor.expand — PyTorch 2.7 documentation

docs.pytorch.org · 4 words · saved by 1 readers

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