AttributeError: module 'torch' has no attribute 'rand'

1. 参考:https://blog.csdn.net/Gao_YaJ/article/details/89578673?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task

2. 问题:今天开始学习pyTorch,按照中文版官方教程进行安装,安装后写了小例程验证是否安装成果,结果出现以下错误

这里提示 AttributeError: module 'torch' has no attribute 'rand'。结果灵机一动,发现自己的py文件叫torch.py,难道是命名冲突吗,不会这么巧吧,于是rename成torch1.py,结果再次运行成功了。

发布了96 篇原创文章 · 获赞 96 · 访问量 22万+

猜你喜欢

转载自blog.csdn.net/qq_33221533/article/details/104978087
今日推荐