AttributeError: module 'torch' has no attribute 'tensor'
时间: 2023-09-25 22:10:36 浏览: 107
出现"AttributeError: module 'torch' has no attribute 'tensor'"错误的原因可能是因为在代码中使用了错误的大小写。在PyTorch中,张量的首字母应为大写"T",而不是小写"t"。因此,正确的写法应该是"torch.Tensor"而不是"torch.tensor"。请检查你的代码,确保正确使用了大小写。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [报错记录:AttributeError: module ‘torch‘ has no attribute ‘Tensor](https://blog.csdn.net/m0_55196097/article/details/126922543)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [module ‘torch‘ has no attribute ‘BoolTensor](https://blog.csdn.net/nangua06/article/details/124665780)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文