当前位置:   article > 正文

AttributeError: module ‘numpy‘ has no attribute ‘float‘.的解决方法

AttributeError: module ‘numpy‘ has no attribute ‘float‘.的解决方法

问题描述

  1. AttributeError: module 'numpy' has no attribute 'float'.
  2. 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.
  3. The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
  4. https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations. Did you mean: 'cfloat'?

原因分析

在较新的NumPy版本中(如,NumPy 1.20),np.float已经被弃用并移除了

解决方法

将dtype=np.float替换为dtype=float或dtype=np.float64

(注意,int类型也同理,需将np.int替换为int或np.int32或np.int64)

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/518068
推荐阅读