numpy.sum()坐标轴问题如何解决

其他教程   发布日期:2023年08月20日   浏览次数:201

今天小编给大家分享一下numpy.sum()坐标轴问题如何解决的相关知识点,内容详细,逻辑清晰,相信大部分人都还太了解这方面的知识,所以分享这篇文章给大家参考一下,希望大家阅读完这篇文章后有所收获,下面我们一起来了解一下吧。

示例

代码如下:

import numpy as np

array = np.array([[1, 1, 1, 1],
                  [2, 2, 2, 2]])

sum_x = np.sum(array, axis=0)
sum_y = np.sum(array, axis=1)
sum_z = np.sum(array, axis=-1)
print("The value of sum_x is: ")
print(sum_x)
print("The value of sum_y is: ")
print(sum_y)
print("The value of sum_z is: ")
print(sum_z)
"""
The value of sum_x is: 
[3 3 3 3]
The value of sum_y is: 
[4 8]
The value of sum_z is: 
[4 8]
"""

以上就是numpy.sum()坐标轴问题如何解决的详细内容,更多关于numpy.sum()坐标轴问题如何解决的资料请关注九品源码其它相关文章!