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

问题描述

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

错误代码行:

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

解决方案

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

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

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

python 复制代码
pip install numpy==1.22.0
  • 解决方案二:

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

python 复制代码
self.sf = int(data['sf'][0,...].squeeze().cpu().numpy()) # scale factor
相关推荐
犽戾武7 小时前
1. 简单回顾Numpy神经网络
人工智能·神经网络·numpy
懒惰蜗牛2 天前
Day10:Python实现Excel自动汇总
python·numpy·pandas·pip·1024程序员节·python读写excel
Kratzdisteln6 天前
【Python】绘制椭圆眼睛跟随鼠标交互算法配图详解
python·数学·numpy·pillow·matplotlib·仿射变换
MoRanzhi12037 天前
Pillow 基础图像操作与数据预处理
图像处理·python·深度学习·机器学习·numpy·pillow·数据预处理
Geoking.8 天前
NumPy zeros() 函数详解
python·numpy
herbal_medicine10 天前
把流量的pcap文件转成其他多种类型的数据(比如序列、图片、自然语言的嵌入),迁移其他领域的模型进行训练。
numpy
jie*12 天前
小杰深度学习(seventeen)——视觉-经典神经网络——MObileNetV3
人工智能·python·深度学习·神经网络·numpy·matplotlib
jie*12 天前
小杰深度学习(sixteen)——视觉-经典神经网络——MobileNetV2
人工智能·python·深度学习·神经网络·tensorflow·numpy·matplotlib
却道天凉_好个秋14 天前
OpenCV(九):NumPy中的矩阵的检索与赋值
opencv·矩阵·numpy