numpy.split
函数沿特定的轴将数组分割为子数组,格式如下:
numpy.split(ary, indices_or_sections, axis)
参数说明:
ary:被分割的数组
indices_or_sections:果是一个整数,就用该数平均切分,如果是一个数组,为沿轴切分的位置(左开右闭)
axis:设置沿着哪个轴的垂直方向进行切分,默认为 0,axis超过数组最大轴报错。
1 import numpy as np 2 3 a = np.arange(16).reshape(2,2,4) 4 print(‘第一个数组:‘) 5 print(a) 6 print(‘\n‘) 7 print(‘默认分割(0轴):‘) 8 b = np.split(a,2,0) 9 print(b) 10 print(‘\n‘)
输出:格式不对,用电脑再跑一边次
一个数组:
[[[ 0 1 2 3]
[ 4 5 6 7]]
[[ 8 9 10 11]
[12 13 14 15]]]
默认分割(0轴):
[array([[[0, 1, 2, 3],
[4, 5, 6, 7]]]), array([[[ 8, 9, 10, 11],
[12, 13, 14, 15]]])]
[Program finished]
numpy.split 函数沿特定的轴将数组分割为子数组(网上解释有错)
原文:https://www.cnblogs.com/casperll/p/14418679.html