今天使用torch出现了这样的警告,
UserWarning: torch.range is deprecated in favor of torch.arange and will be removed in 0.5. Note that arange generates values in [start; end), not [start; end].
代码如下:
a = torch.range(1,16).reshape(4,4)
print(a,a.size())
b = torch.prod(a,1,True)
print(b,b.size())
查询过后是这样的原因:区间不符合主流
a = torch.arange(0,16).reshape(4,4)
这样改动后便好了
本文解决了在使用PyTorch时遇到的torch.range被弃用的警告问题,介绍了正确的替代方法torch.arange,并提供了代码示例。
891

被折叠的 条评论
为什么被折叠?



