python reshape -1
2017-12-05 10:56
260 查看
z.reshape(-1) array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16])
z.reshape(-1, 1)
也就是说,先前我们不知道z的shape属性是多少,但是想让z变成只有一列,行数不知道多少,通过`z.reshape(-1,1)`,Numpy自动计算出有12行,新的数组shape属性为(16, 1),与原来的(4, 4)配套。
z.reshape(-1,1) array([[ 1], [ 2], [ 3], [ 4], [ 5], [ 6], [ 7], [ 8], [ 9], [10], [11], [12], [13], [14], [15], [16]])
作者:李彬
链接:https://www.zhihu.com/question/52684594/answer/157491724
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
相关文章推荐
- Python中reshape函数参数-1的意思
- MATLAB 与python reshape 比较
- Python——数组重组(flatten、flat、ravel、reshape、resize)
- python中reshape的负参数
- 【python】numpy库ndarray多维数组的维度变换方法:reshape、resize、swapaxes、flatten等详解与实例
- python3 reshape 小技巧
- 解决Python问题Reshape your data either using array.reshape(-1, 1) if your data has a single feature or a
- [python]image(reshape,overlay)
- Python&OpenCV - 随机生成图像 与 图像的转维(reshape)
- Python Numpy中reshape函数参数-1的含义
- Python Numpy Tutorials: 数组中数学函数及变形(reshape)
- Matlab与Python中find/where、reshape、eig的区别
- python reshape()函数ValueError: total size of new array must be unchanged
- tensorflow.python.framework.errors.InvalidArgumentError: Input to reshape is a tensor with xxx value
- Python numpy函数:reshape()
- Python:numpy中shape和reshape的用法
- python2.7中用numpy.reshape 对图像进行切割
- python库numpy的reshape的终极解释
- Python Intro - type range and reshape
- python numpy 如何获取和更改数组(array)的形状、维数-shape&reshape