pytorch.range() 和 pytorch.arange() 的区别
- torch.range(start=1, end=6) 的结果是会包含end的,而torch.arange(start=1, end=6)的结果并不包含end。
- 两者创建的tensor的类型也不一样
>>> 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