报错:‘numpy‘ has no attribute ‘float‘.

报错:

'numpy' has no attribute 'float'.
`np.float` was a deprecated alias for the builtin `float`. To avoid this error in existing code, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.

报错原因:

从numpy1.24起删除了numpy.bool、numpy.int、numpy.float、numpy.complex、numpy.object、numpy.str、numpy.long、numpy.unicode类型的支持。

解决办法

方法一:修改numpy版本
安装numpy1.24之前的版本

pip install numpy==1.23.5

方法二:修改代码

np.float替换为float或者np.float64/np.float3

猜你喜欢

转载自blog.csdn.net/qq_32636415/article/details/134870104
今日推荐