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,結果再次運行成功了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章