当前位置:   article > 正文

AttributeError: module ‘numpy‘ has no attribute ‘float‘.的解决方法_`np.float` was a deprecated alias for the builtin

`np.float` was a deprecated alias for the builtin `float`. to avoid this err

问题描述

  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博客】
推荐阅读
相关标签
  

闽ICP备14008679号