AttributeError: module ‘numpy‘ has no attribute ‘int‘.

简介: AttributeError: module ‘numpy‘ has no attribute ‘int‘.

问题描述

复现代码过程中遇到错误:AttributeError: module 'numpy' has no attribute 'int'.


错误代码行:

self.sf = np.int(data['sf'][0,...].squeeze().cpu().numpy()) # scale factor


解决方案

这是因为在Numpy 1.2.0版本中就已经弃用了这个用法:np.int。先来看一下我的numpy版本:


  • 解决方案一(不推荐):

       修改numpy版本,改为 numpy==1.22.0

pip install numpy==1.22.0



  • 解决方案二:

修改报错行代码,将来 np.int 修改为 int

self.sf = int(data['sf'][0,...].squeeze().cpu().numpy()) # scale factor

目录
相关文章
|
23天前
|
Python
A module that was compiled using NumPy 1.x cannot be run in NumPy 2.0.0 as it may crash. To support
本文讨论了在NumPy 2.0.0版本更新后可能出现的兼容性问题,并提供了通过降级NumPy版本至1.x的解决方法,以支持尚未更新的模块或库。
|
1月前
|
Python
module 'numpy' has no attribute 'int'.
module 'numpy' has no attribute 'int'.
70 0
|
4月前
|
Python
AttributeError: module ‘numpy‘ has no attribute ‘int‘.
AttributeError: module ‘numpy‘ has no attribute ‘int‘.
76 0
|
4月前
|
Shell 计算机视觉 Python
no module named cv2 、numpy 、xxx超全解决方案
no module named cv2 、numpy 、xxx超全解决方案
93 0
|
4月前
|
Ubuntu 定位技术 Python
numpy库报错has no attribute ‘_no_nep50_warning‘的解决
numpy库报错has no attribute ‘_no_nep50_warning‘的解决
106 1
|
4月前
|
数据采集 分布式计算 数据处理
Dataphin常见问题之与指定类型int不兼容如何解决
Dataphin是阿里云提供的一站式数据处理服务,旨在帮助企业构建一体化的智能数据处理平台。Dataphin整合了数据建模、数据处理、数据开发、数据服务等多个功能,支持企业更高效地进行数据治理和分析。
|
4月前
|
SQL 流计算 OceanBase
OceanBase CDC从热OB库采集过来的Tinyint(1)类型会默认转换成Boolean,请教一下,如果想转换成int类型,有什方法么?
【2月更文挑战第25天】OceanBase CDC从热OB库采集过来的Tinyint(1)类型会默认转换成Boolean,请教一下,如果想转换成int类型,有什方法么?
114 3
|
1月前
|
Java
【Java基础面试五】、 int类型的数据范围是多少?
这篇文章回答了Java中`int`类型数据的范围是-2^31到2^31-1,并提供了其他基本数据类型的内存占用和数值范围信息。
【Java基础面试五】、 int类型的数据范围是多少?
|
1月前
|
自然语言处理 Go 数据安全/隐私保护
对 int 类型的数据加密,有哪些好的方案?
对 int 类型的数据加密,有哪些好的方案?
63 13
|
3月前
|
机器学习/深度学习 人工智能 分布式计算
人工智能平台PAI产品使用合集之int类型是否可以为raw feature
阿里云人工智能平台PAI是一个功能强大、易于使用的AI开发平台,旨在降低AI开发门槛,加速创新,助力企业和开发者高效构建、部署和管理人工智能应用。其中包含了一系列相互协同的产品与服务,共同构成一个完整的人工智能开发与应用生态系统。以下是对PAI产品使用合集的概述,涵盖数据处理、模型开发、训练加速、模型部署及管理等多个环节。