D:\python3.10\lib\site-packages\torch\nn\modules\linear.py:96: UserWarning: Failed to initialize NumPy: module compiled against API version 0x10 but this version of numpy is 0xf . Check the section C-API incompatibility at the Troubleshooting ImportError section at https://numpy.org/devdocs/user/troubleshooting-importerror.html#c-api-incompatibility for indications on how to solve this problem . (Triggered internally at ..\torch\csrc\utils\tensor_numpy.cpp:84.) self.weight = Parameter(torch.empty((out_features, in_features), **factory_kwargs)) Traceback (most recent call last): File "C:\Users\admin\PycharmProjects\dl1test\main.py", line 46, in <module> data_train = torch.tensor(x_train).float() RuntimeError: Could not infer dtype of numpy.uint8
时间: 2023-06-06 17:05:16 浏览: 321
python 3.74 运行import numpy as np 报错lib\site-packages\numpy\__init__.py
这个警告提示是因为 NumPy 的版本和 Torch 包中的线性层模块不兼容,需要通过查看在 https://numpy.org/devdocs/user/troubleshooting-importerror.html 中关于 C-API 不兼容的部分来解决 ImportError 的问题。
阅读全文