首页 > 编程知识 正文

numpy sum函数,python reshape函数

时间:2023-05-04 07:49:11 阅读:111758 作者:2676

3358 blog.csdn.net/Zeng Haitao 0128/article/details/78512715

reshape函数:更改数组的维数(注意不是形状大小)

e=NP.arange(10 ) earray ) [ 0,1,2,3,4,5,6,7,8,9 ] ) e.reshape ) 1,1,10 ) array [ 0,1,2,2 ] 3

用法: numpy.squeeze(a,axis=None ) )。

1 ) a表示输入数组2 ) axis用于指定要删除的维,但指定的维必须是单维。 否则会发生错误。 3 ) axis的值为None、int或tuple of ints,可选。 如果axis为空,则删除所有一维条目; 4 )返回值:数组5 )不修改原始数组;

a=e.reshape (1,1,10 ) aarray ) [ [ 0,1,2,3,4,5,6,7,8,9 ] ] NP.squeeze ) (a ) aarray ),0,1,1,0

squeeze 函数:

PLT.plot(a )跟踪后退(杂项) :文件(stdin ),line 1,inmodulefile ) c:(python27 ) lib(siib **kwargs )文件' c : (python 27 (站点打包(lib )映射) )。 ninnerreturnfunc(ax、*args、**kwargs )文件' c : (python 27 (lib (site-packages ) matplotlib (axes ) _ ) ) inplotforlineinself._ get _ lines (args,**kwargs ) :文件' c : (python 27 (lib ) site-packages ) matpppes in kwargs ) :文件' c : (python 27 (lib ) site-Pacce in _plot_args x,y=self._xy_from_xy(x, y )文件' c : (python 27 (lib (site-packages ) matplotlling in _ xy _ from _ xy ' shapes { } and { }.format (x.) y.shape ) ) value error : xandycanbenogreaterthan2- d 10l ) PLT.plot(NP.squeeze(a ) ) matplotlib.lines.line

使用np.squeeze(a ).shape (10l,)函数转换NP.squeeze )时,显示的数组为秩1数组,即) 10,"

参考: http://blog.csdn.net/Zeng Haitao 0128/article/details/78512715

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。