热线电话:13121318867

登录
2018-12-03 阅读量: 711
轴参数的示例

尺寸为3 x 3 x 3的三维阵列,在其三个轴中的每个轴上求和

>>>>>> x array([[[ 0,  1,  2],         [ 3,  4,  5],         [ 6,  7,  8]],        [[ 9, 10, 11],         [12, 13, 14],         [15, 16, 17]],        [[18, 19, 20],         [21, 22, 23],         [24, 25, 26]]]) 
>>> x.sum(axis=0) array([[27, 30, 33], [36, 39, 42], [45, 48, 51]])
>>> # for sum, axis is the first keyword, so we may omit it,
>>> # specifying only its value
>>> x.sum(0), x.sum(1), x.sum(2) (array([[27, 30, 33], [36, 39, 42], [45, 48, 51]]), array([[ 9, 12, 15], [36, 39, 42], [63, 66, 69]]), array([[ 3, 12, 21], [30, 39, 48], [57, 66, 75]]))
0.0000
2
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子