import torch
y = torch.range(1, 6)
print(y)
print(y.dtype)
z = torch.arange(0, 6)
print(z)
print(z.dtype)
结果:数据类型不一样,长度不一样,可以按自己的需求选择合适的
tensor([1., 2., 3., 4., 5., 6.])
torch.float32
tensor([0, 1, 2, 3, 4, 5])
torch.int64