当前位置:网站首页>numpy之 警告VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences
numpy之 警告VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences
2022-07-03 03:23:00 【水w】
目录
警告
这是我写的读取npz文件的代码,
datas = np.load("bsm.npz", allow_pickle=True)
print(datas.files)
for key, arr in datas.items():
print(key, ": ", arr)执行代码之后,可以输出预期的结果,但也得到了警告,如下:
VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray.
val = np.asanyarray(val)
解决
其实这不是错误,只是新版numpy的一个警告,可以忽略。当然总是显示影响美观,可以直接关闭该警告。
这是因为新的numpy版本,将 创建不同长度或形状的列表或元组或ndarray的列表或ndarray元组的功能 会被弃用,虽然能够运行,但是总提示Warning还是很不舒服,况且之后也不能这样用了。
尝试网传的解决方法:
- 使用更早的numpy版本
- 添加dtype=object
- 添加一行忽视报错代码
(1)尝试一下网上有种说法是添加“dtype=object”,
# 3.加载数据
datas = np.load("bsm.npz", allow_pickle=True, dtype=object)
print(datas.files)
for key, arr in datas.items():
print(key, ": ", arr)
但是还是报错,甚至都不会输出结果了,

(2)我们再尝试网上还有一种说法是:numpy的版本过高,需要降低numpy的版本。
查看了自己的numpy的版本,我现在的numpy版本是1.23.0,

好吧,那我们来重新安装一下低版本的numpy试试,

等待安装完成的过程中,报错了,

好吧。
(3)在网上还看见一种说法:
np.warnings.filterwarnings('ignore', category=np.VisibleDeprecationWarning)
或
np.warnings.filterwarnings('error', category=np.VisibleDeprecationWarning)我们来试试,

好像没什么用。。。。。。
(4)最后还是决定忽视它......
边栏推荐
- File rename
- Hi3536C V100R001C02SPC040 交叉编译器安装
- Vs 2019 configure tensorrt to generate engine
- On the adjacency matrix and adjacency table of graph storage
- Gavin teacher's perception of transformer live class - rasa project's actual banking financial BOT Intelligent Business Dialogue robot architecture, process and phenomenon decryption through rasa inte
- Pytoch lightweight visualization tool wandb (local)
- Basic information of Promethus (I)
- The file marked by labelme is converted to yolov5 format
- Spark on yarn resource optimization ideas notes
- Distributed transaction
猜你喜欢

Pytoch lightweight visualization tool wandb (local)

900w+ data, from 17s to 300ms, how to operate
![C programming learning notes [edited by Mr. Tan Haoqiang] (Chapter III sequence programming) 03 operators and expressions](/img/4a/1df03d9f3315debb4c335260ed39f2.jpg)
C programming learning notes [edited by Mr. Tan Haoqiang] (Chapter III sequence programming) 03 operators and expressions

Avec trois. JS fait une scène 3D simple

Gavin teacher's perception of transformer live class - rasa project's actual banking financial BOT Intelligent Business Dialogue robot architecture, process and phenomenon decryption through rasa inte

Unity3d RPG implementation (medium)

Vs 2019 installation and configuration opencv

Don't use the new Dede collection without the updated Dede plug-in

VS 2019配置tensorRT

Small guide for rapid formation of manipulator (VIII): kinematic modeling (standard DH method)
随机推荐
Pytoch configuration
C programming learning notes [edited by Mr. Tan Haoqiang] (Chapter III sequence programming) 05 data input and output
I2C subsystem (I): I2C spec
MySQL practice 45 [SQL query and update execution process]
PAT乙级“1104 天长地久”DFS优化思路
Basic information of Promethus (I)
C# WebRequest POST模式 ,基于“Basic Auth”口令认证模式,使用multipart/form-data方式上传文件及提交其他数据
900W+ 数据,从 17s 到 300ms,如何操作
[AI practice] Application xgboost Xgbregressor builds air quality prediction model (I)
Small guide for rapid formation of manipulator (VIII): kinematic modeling (standard DH method)
Vs 2019 configure tensorrt to generate engine
Creation and destruction of function stack frame
Gavin teacher's perception of transformer live class - rasa project's actual banking financial BOT Intelligent Business Dialogue robot architecture, process and phenomenon decryption through rasa inte
umi 路由拦截(简单粗暴)
Model transformation onnx2engine
The file marked by labelme is converted to yolov5 format
ComponentScan和ComponentScans的区别
文件重命名
Pytoch lightweight visualization tool wandb (local)
@Accessors annotation function specifies that the prefix follows the hump naming