PyTorch is an open-source machine learning library developed by Facebook. It is used for deep neural network and natural language processing purposes.
The function torch.empty()
returns a tensor filled with uninitialized data. The shape of the tensor is defined by the variable argument size.
Syntax: torch.empty(size, out=None)
Parameters:
size: a sequence of integers defining the shape of the output tensor
out (Tensor, optional): the output tensor
Return type: A tensor
Code #1:
import torch
a = torch.empty([ 3 , 4 ])
print ( "a = " , a)
b = torch.empty([ 2 , 3 ])
print ( "b = " , b)
|
Output:
a = tensor([[2.0283e-19, 6.9772e+22, 1.8943e+23, 1.1432e-32],
[1.3563e-19, 1.8888e+31, 8.9066e-15, 1.8888e+31],
[6.4639e-04, 6.8608e+22, 1.7753e+28, 2.0535e-19]])
b = tensor([[0., 0., 0.],
[0., 0., 0.]])