[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)

Published by

风君子

独自遨游何稽首 揭天掀地慰生平

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注