当前位置:网站首页>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)最后还是决定忽视它......
边栏推荐
- Parameter index out of range (1 > number of parameters, which is 0)
- Pytoch lightweight visualization tool wandb (local)
- Use of check boxes: select all, deselect all, and select some
- The difference between componentscan and componentscans
- [error record] the parameter 'can't have a value of' null 'because of its type, but the im
- MySql实战45讲【SQL查询和更新执行流程】
- Unity3d RPG implementation (medium)
- C# WebRequest POST模式 ,基于“Basic Auth”口令认证模式,使用multipart/form-data方式上传文件及提交其他数据
- Lvgl usage experience
- Pat class B common function Usage Summary
猜你喜欢

umi 路由拦截(简单粗暴)
![MySQL practice 45 [global lock and table lock]](/img/23/fd58c185ae49ed6c04f1a696f10ff4.png)
MySQL practice 45 [global lock and table lock]

Pat class B "1104 forever" DFS optimization idea

Force deduction ----- the minimum path cost in the grid

3D drawing example

PAT乙级“1104 天长地久”DFS优化思路

Idea format code idea set shortcut key format code

Anhui University | small target tracking: large-scale data sets and baselines

Limit of one question per day

Docker install MySQL
随机推荐
[error record] the parameter 'can't have a value of' null 'because of its type, but the im
403 error displayed when vs cloning
复选框的使用:全选,全不选,选一部分
【AI实战】应用xgboost.XGBRegressor搭建空气质量预测模型(一)
MongoDB安装 & 部署
Don't use the new Dede collection without the updated Dede plug-in
Edit and preview in the back pipe to get the value writing method of the form
Vs 2019 configuration tensorrt
Pytoch configuration
使用InputFilter限制EditText时踩坑及解决方案
The idea setting code is in UTF-8 idea Properties configuration file Chinese garbled
Destroy the session and empty the specified attributes
MySql实战45讲【事务隔离】
MySQL practice 45 lecture [row lock]
[algebraic structure] group (definition of group | basic properties of group | proof method of group | commutative group)
com.fasterxml.jackson.databind.exc.InvalidFormatException问题
PAT乙级常用函数用法总结
Last update time of all sqlserver tables
Stop using system Currenttimemillis() takes too long to count. It's too low. Stopwatch is easy to use!
[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