[python]numpy.mean()用法

a=np.array([[[1,1],[2,2],[3,3]],[[4,4],[5,5],[6,6]],[[7,7],[8,8],[9,9]],[[10,10],[11,11],[12,12]]])
print a
print a.shape
b=a.mean(0).shape
c=a.mean(1).shape
d=a.mean(2).shape
print b
print c
print d

output:

[[[ 1  1]
  [ 2  2]
  [ 3  3]]

 [[ 4  4]
  [ 5  5]
  [ 6  6]]

 [[ 7  7]
  [ 8  8]
  [ 9  9]]

 [[10 10]
  [11 11]
  [12 12]]]
(4, 3, 2)
(3, 2)
(4, 2)
(4, 3)

 

posted @ 2018-04-20 16:07  Runtime69  阅读(8237)  评论(0编辑  收藏  举报