代码语言:javascript复制
>>> y=torch.range(1,6)
>>> y
tensor([1., 2., 3., 4., 5., 6.])
>>> y.dtype
torch.float32
>>> z=torch.arange(1,6)
>>> z
tensor([1, 2, 3, 4, 5])
>>> z.dtype
torch.int64总结:
torch.range(start=1, end=6)的结果是会包含end的, 而torch.arange(start=1, end=6)的结果并不包含end。- 两者创建的
tensor的类型也不一样。


