April 8, 2024, 9:35 p.m. | Super Kai (Kazuya Ito)

DEV Community dev.to

empty() can create a 1D or more D tensor filled with the zero or more numbers in memory which is called uninitialized data.


*Memos:



  • You can use torch.Tensor() or torch.FloatTensor() like torch.Tensor(3, 2, 4) or torch.FloatTensor(3, 2, 4) because they can do the same job as empty(). *torch.Tensor() is the alias of torch.FloatTensor() by default.


  • empty() can be used only from torch but not from a tensor



import torch

torch.empty(0)
torch.empty((0,))
# tensor([])

torch.empty(3)
torch.empty((3,))
# tensor([-1.3610e+13, 4.4916e-41, -1.3610e+13]) …

data empty job memory memos numbers pytorch tensor torch

Data Architect

@ University of Texas at Austin | Austin, TX

Data ETL Engineer

@ University of Texas at Austin | Austin, TX

Lead GNSS Data Scientist

@ Lurra Systems | Melbourne

Senior Machine Learning Engineer (MLOps)

@ Promaton | Remote, Europe

C003549 Data Analyst (NS) - MON 13 May

@ EMW, Inc. | Braine-l'Alleud, Wallonia, Belgium

Marketing Decision Scientist

@ Meta | Menlo Park, CA | New York City