Pytorch is creating non empty Tensor with torch.empty((x,y)
I just want to create an empty tensor containing only zero values. but here is what I am getting so far. Source: https://pytorch.org/docs/stable/generated/torch.empty.html
a=torch.empty((2,3), dtype=torch.int32, device = 'cuda')
a
tensor([[16843009, 1, 1],
[ 0, 1, 0]], device='cuda:0', dtype=torch.int32)
Screenshot as proof:
My question is, Why?? Is it a bug or what
If you want a tensor of zeros, use torch.zeros
.
torch.empty
allocates a tensor but it does not initialise the contents, meaning that the tensor will contain whatever data happened to occupy that region of memory already.