keepdims主要用于保持矩阵的二维特性

import numpy as np
a = np.array([[1,2],[3,4]])

# 按行相加,并且保持其二维特性
print(np.sum(a, axis=1, keepdims=True))

# 按行相加,不保持其二维特性
print(np.sum(a, axis=1))

 

输出

array([[3], [7]])
array([3, 7])

--------------------------------------------------------------

转载自:http://blog.csdn.net/u012560212/article/details/78393836

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-29
  • 2021-12-26
  • 2021-08-26
  • 2021-11-04
  • 2022-02-14
猜你喜欢
  • 2022-01-17
  • 2022-02-07
  • 2022-12-23
  • 2022-12-23
  • 2022-01-21
  • 2022-12-23
  • 2021-04-15
相关资源
相似解决方案