生成与括号元素中同样维度的tensor;并且全部都是0
X=torch.arange(12).reshape(3,4)
print(X)
Y=torch.zeros_like(X)
print(Y)
tensor([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11]])
tensor([[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0]])
X=torch.arange(12).reshape(3,4)
print(X)
Y=torch.zeros_like(X)
print(Y)
tensor([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11]])
tensor([[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0]])