reshape, transpose, resize的区别

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xiaojiajia007/article/details/82148336

numpy.reshape takes a shape as input, and format array into that shape. An intuitive way to think of it is that Numpy flattens your array into a plain list, and truncate the long flattened list into the new form. 

The transpose method from Numpy also takes axes as input so you may change what axes to invert, this is very useful for a tensor. Eg. data.transpose(1,0,2) where 012 stands for the axes. The 0 refers to the outermost array.

具体说明见 https://lihan.me/2018/01/numpy-reshape-and-transpose/

resize与reshape,ravel与flatten的区别 https://blog.csdn.net/li1615882553/article/details/79255581

维度改变分类:  https://blog.csdn.net/weixin_40040404/article/details/80779785
- 1)视图变维:数据共享,同时改变 
- ……a.reshape(n,m…), a.ravel() 
- 2)复制变维:复制数据且数据相互独立,改变相互不影响 
- ……a.flatten() 
- 3)就地变维 
- ……a.resize((3,2)) / a.shape = (3,2) 
- 4)视图转置:数据共享,同时改变 
- ……a.transpose() (前提a.shape[0]>1) 
- ……a.reshape(-1,1)

猜你喜欢

转载自blog.csdn.net/xiaojiajia007/article/details/82148336