创建一个 tensor 基于已经存在的 tensor。
错误的源代码:
x = x.new_ones(5, 3, dtype=torch.double)
# new_* methods take in sizes
print(x)
x = torch.randn_like(x, dtype=torch.float)
# override dtype!
print(x)
# result has the same size
修改后的源代码:
x = torch.ones(5, 3, dtype=torch.double)
print(x)
X4 = torch.randn_like(x, dtype=torch.float)
print(X4)