python中squeeze函数_Pythonnumpy.squeeze函数方法的使用

更新时间:2023-05-22 17:00:33 阅读: 评论:0

python中squeeze函数_Pythonnumpy.squeeze函数⽅法的使
numpy.squeeze
numpy.squeeze(a, axis=None)    [source]
从数组shape中删除⼀维条⽬。参数 :a :array_like
walk the walk输⼊数据。
ironcurtain
进击的巨人英文axis :None 或 int 或 int类型的tuple, 可选
缺点英语1.7.0版中的新功能。
选择形状中⼀维条⽬的⼦集。
如果选择的形状输⼊⼤于⼀个的轴,则会引发错误。
返回值 :squeezed :ndarray
输⼊数组,但删除了长度为1的全部或部分维度。
可能始终是其本⾝或a的视图。
请注意,如果所有轴都受到squeeze,则结果为0d数组,⽽不是标量。
Rais :ValueError
如果axis不为None,并且被压缩的轴的长度不为1
例⼦>>> x = np.array([[[0], [1], [2]]])
>>> x.shape
考研政治怎么复习(1, 3, 1)
>>> np.squeeze(x).shape清白的意思
(3,)
>>> np.squeeze(x, axis=0).shape
(3, 1)
>>> np.squeeze(x, axis=1).shape
Traceback (most recent call last):
...
ValueError: cannot lect an axis to squeeze out which has size not equal to one
>>> np.squeeze(x, axis=2).shape
key to happiness(1, 3)
>>> x = np.array([[1234]])美女上错身第四季
rnc>>> x.shape
(1, 1)
>>> np.squeeze(x)
array(1234) # 0d array >>> np.squeeze(x).shape ()
visco>>> np.squeeze(x)[()] 1234

本文发布于:2023-05-22 17:00:33,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/78/734301.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:数组   删除   维条
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图