Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PyTorch torch.empty function

PyTorch torch.empty function


PyTorch torch reference manual PyTorch torch reference manual

torch.empty is a PyTorch function for creating an uninitialized tensor.

Function definition

torch.empty(*size, dtype=None, device=None, requires_grad=False)


Usage examples

Example

import

torch

Create an uninitialized tensor

x

=

torch.

empty

(

3

,

4

)

print

(

x

)

print

(

"Note: values are uninitialized memory values"

)


PyTorch torch reference manual PyTorch torch reference manual