当前位置:网站首页>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)最后还是决定忽视它......
边栏推荐
- 复选框的使用:全选,全不选,选一部分
- VS克隆时显示403错误
- 模糊查询时报错Parameter index out of range (1 > number of parameters, which is 0)
- Stepping on pits and solutions when using inputfilter to limit EditText
- 900w+ data, from 17s to 300ms, how to operate
- Réglez la hauteur et lancez le système. Currenttimemillis catton
- PHP constructor with parameters - PHP constructor with a parameter
- 用Three.js做一個簡單的3D場景
- MongoDB简介
- C programming learning notes [edited by Mr. Tan Haoqiang] (Chapter III sequence programming) 05 data input and output
猜你喜欢
Idea set method call ignore case
idea 加载不了应用市场解决办法(亲测)
Latest version of NPM: the "NPM" item cannot be recognized as the name of a cmdlet, function, script file, or runnable program. Please check
VS 2019配置tensorRT
The calculation of stripe, kernel and padding in CNN
Vs 2019 configure tensorrt to generate engine
Distributed transaction
45 lectures on MySQL [index]
TCP handshake three times and wave four times. Why does TCP need handshake three times and wave four times? TCP connection establishes a failure processing mechanism
VS code配置虚拟环境
随机推荐
Pytorch配置
Compare float with 0
com.fasterxml.jackson.databind.exc.InvalidFormatException问题
The idea cannot be loaded, and the market solution can be applied (pro test)
idea 加载不了应用市场解决办法(亲测)
[combinatorics] number of solutions of indefinite equations (number of combinations of multiple sets R | number of non negative integer solutions of indefinite equations | number of integer solutions
[pyg] understand the messagepassing process, GCN demo details
Edit and preview in the back pipe to get the value writing method of the form
I2C subsystem (I): I2C spec
二进制流转换成字节数组
Agile certification (professional scrum Master) simulation exercises
Variable declarations following if statements
将时间戳转为指定格式的时间
[algebraic structure] group (definition of group | basic properties of group | proof method of group | commutative group)
BigVision代码
Nasvit: neural architecture search of efficient visual converter with gradient conflict perception hypernetwork training
MySql实战45讲【行锁】
VS 2019配置tensorRT
Pytoch configuration
二维数组中的元素求其存储地址