基础部分之numpy 调整数组维度 resize
调整数组维度 resize
用法
resize(numpy.ndarray, axes=[])
axes: 必须参数,修改维度,给出每个维度的长度
实例:IPython 交互
>>> import numpy as np
>>> a = np.arange(16).reshape(2, 8)
>>> a
array([[ 0, 1, 2, 3, 4, 5, 6, 7],
[ 8, 9, 10, 11, 12, 13, 14, 15]])
>>> np.resize(a, [4,4])
array([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11],
[12, 13, 14, 15]])
>>> np.resize(a, [2,2,4])
array([[[ 0, 1, 2, 3],
[ 4, 5, 6, 7]],
[[ 8, 9, 10, 11],
[12, 13, 14, 15]]])
如果觉得本文有用,万望看官慷慨解囊,不吝打赏,激励本编提供更加优质的内容
[点击进行打赏](https://www.cnblogs.com/52note/p/16507868.html)