当前位置:网站首页>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)最后还是决定忽视它......
边栏推荐
- Converts a timestamp to a time in the specified format
- Force deduction ----- the minimum path cost in the grid
- Stepping on pits and solutions when using inputfilter to limit EditText
- Vs 2019 installation and configuration opencv
- Use of check boxes: select all, deselect all, and select some
- el-tree搜索方法使用
- Compare float with 0
- Edit and preview in the back pipe to get the value writing method of the form
- MySQL practice 45 [global lock and table lock]
- 为什么线程崩溃不会导致 JVM 崩溃
猜你喜欢
Anhui University | small target tracking: large-scale data sets and baselines
Vs Code configure virtual environment
Vs 2019 configuration du moteur de génération de tensorrt
VS 2019配置tensorRT
Pytorch轻量级可视化工具wandb(local)
3D drawing example
用Three.js做一个简单的3D场景
The idea setting code is in UTF-8 idea Properties configuration file Chinese garbled
用Three.js做一個簡單的3D場景
Stop using system Currenttimemillis() takes too long to count. It's too low. Stopwatch is easy to use!
随机推荐
Basic information of Promethus (I)
C# WebRequest POST模式 ,基于“Basic Auth”口令认证模式,使用multipart/form-data方式上传文件及提交其他数据
[shutter] monitor the transparency gradient of the scrolling action control component (remove the blank of the top status bar | frame layout component | transparency component | monitor the scrolling
C#通用接口调用
基于Qt的yolov5工程
二维数组中的元素求其存储地址
umi 路由拦截(简单粗暴)
MySql实战45讲【全局锁和表锁】
Bigvision code
PAT乙级常用函数用法总结
[set theory] partial order relation (partial order relation definition | partial order set definition | greater than or equal to relation | less than or equal to relation | integer division relation |
MongoDB主配置文件
Vs 2019 configure tensorrt to generate engine
@Accessors注解作用指定前缀遵守驼峰命名
MongoDB复制集【主从复制】
Small guide for rapid formation of manipulator (VIII): kinematic modeling (standard DH method)
Last update time of all sqlserver tables
Summary of matrix knowledge points in Chapter 2 of Linear Algebra (Jeff's self perception)
用Three.js做一个简单的3D场景
Limit of one question per day