PyTorch
PyTorch 기본 함수 정리 (Ones, Zeros)
수터디
2022. 6. 18. 12:32
x = torch.FloatTensor([[0, 1, 2], [2, 1, 0]])
print(x)
# tensor([[0., 1., 2.],
# [2., 1., 0.]])
print(torch.ones_like(x)) # device도 동일하게 간다. 같은 device에 텐서 선언
print(torch.zeros_like(x))
# tensor([[1., 1., 1.],
# [1., 1., 1.]])
# tensor([[0., 0., 0.],
# [0., 0., 0.]])