当前位置:网站首页>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)最后还是决定忽视它......
边栏推荐
- Stepping on pits and solutions when using inputfilter to limit EditText
- Distributed transaction
- LVGL使用心得
- Latest version of NPM: the "NPM" item cannot be recognized as the name of a cmdlet, function, script file, or runnable program. Please check
- Left connection, inner connection
- Spark on yarn resource optimization ideas notes
- Change and access of median value of listening object
- Use of check boxes: select all, deselect all, and select some
- The difference between componentscan and componentscans
- Edit and preview in the back pipe to get the value writing method of the form
猜你喜欢
![MySQL practice 45 lecture [transaction isolation]](/img/a5/5420651d6be51e892976f02be8c43c.png)
MySQL practice 45 lecture [transaction isolation]

VS 2019 配置tensorRT生成engine
![MySQL practice 45 [global lock and table lock]](/img/23/fd58c185ae49ed6c04f1a696f10ff4.png)
MySQL practice 45 [global lock and table lock]

Hi3536c v100r001c02spc040 cross compiler installation

MongoDB简介

MongoDB复制集【主从复制】

Creation and destruction of function stack frame

别再用 System.currentTimeMillis() 统计耗时了,太 Low,StopWatch 好用到爆!

MySql实战45讲【全局锁和表锁】

Stop using system Currenttimemillis() takes too long to count. It's too low. Stopwatch is easy to use!
随机推荐
Converts a timestamp to a time in the specified format
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
Edit and preview in the back pipe to get the value writing method of the form
idea 加载不了应用市场解决办法(亲测)
MongoDB安装 & 部署
二进制流转换成字节数组
C programming learning notes [edited by Mr. Tan Haoqiang] (Chapter III sequence programming) 03 operators and expressions
渤、黄海的潮汐特征
Tidal characteristics of the Bohai Sea and the Yellow Sea
Stop using system Currenttimemillis() takes too long to count. It's too low. Stopwatch is easy to use!
[Chongqing Guangdong education] cultural and natural heritage reference materials of China University of Geosciences (Wuhan)
45 lectures on MySQL [index]
900W+ 数据,从 17s 到 300ms,如何操作
Vs 2019 configuration tensorrt
900w+ data, from 17s to 300ms, how to operate
[mathematical logic] normal form (conjunctive normal form | disjunctive normal form | major item | minor item | maximal item | minor item | principal conjunctive normal form | principal disjunctive no
ComponentScan和ComponentScans的区别
[mathematical logic] predicate logic (individual word | individual domain | predicate | full name quantifier | existence quantifier | predicate formula | exercise)
el-tree搜索方法使用
别再用 System.currentTimeMillis() 统计耗时了,太 Low,StopWatch 好用到爆!