二维数组

axis=0:表示从上往下

axis=1:表示从左往右

temp = np.array([[1, 2], [3, 4]])
print("原矩阵数组:\n",temp)
axis0 = temp.sum(0) #从上到下求和
axis1 = temp.sum(1) #从左往右求和
print("axis0(从上到下求和):", axis0)
print("axis0(从左往右求和):", axis1)

三维数组


temp = np.array([[[1, 2],[3, 4]], [[5, 6], [7, 8]]])
print("原矩阵数组:\n",temp)
axis0 = temp.sum(0) #沿着通道层数方向求和
axis1 = temp.sum(1) #从上到下求和
axis2 = temp.sum(2) #从左往右求和
print("axis0:\n", axis0)
print("axis1:\n", axis1)
print("axis2:\n", axis2)

从 sum 求和谈 axis=1 or 0的更多相关文章

  1. 1.求整数最大的连续0的个数 BinaryGap Find longest sequence of zeros in binary representation of an integer.

    求整数最大的连续0的个数 A binary gap within a positive integer N is any maximal sequence of consecutive zeros t ...

  2. [LeetCode] Binary Tree Maximum Path Sum 求二叉树的最大路径和

    Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree. ...

  3. [LeetCode] 124. Binary Tree Maximum Path Sum 求二叉树的最大路径和

    Given a non-empty binary tree, find the maximum path sum. For this problem, a path is defined as any ...

  4. 数位DP 求K进制下0~N的每个数每位上出现的数的总和

    好久没写博客了,因为感觉时间比较紧,另一方面没有心思,做的题目比较浅也是另一方面. 热身赛第二场被血虐了好不好,于是决定看看数位DP吧. 进入正题: 如题是一道经(简)典(单)的数位dp. 第一步,对 ...

  5. HDU1003 Max Sum(求最大字段和)

    事实上这连续发表的三篇是一模一样的思路,我就厚颜无耻的再发一篇吧! 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1003 -------------- ...

  6. HDU 1003 Max Sum 求区间最大值 (尺取法)

    Max Sum Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Su ...

  7. poj 3348 Cows 凸包 求多边形面积 计算几何 难度:0 Source:CCC207

    Cows Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7038   Accepted: 3242 Description ...

  8. [Leetcode] Binary tree maximum path sum求二叉树最大路径和

    Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree. ...

  9. SGU 231 Prime Sum 求<=n内有多少对素数(a,b)使得a+b也为素数 规律题

    题目链接:contest=0&problem=231">点击打开链接 题意: 求<=n内有多少对素数(a,b)使得a+b也为素数 思路: 我们发现全部素数间隔都是> ...

  10. 创建sum求多元素的和

    a = [1, 2, 3] b = [4, 5, 6] def sum_super(* args): s = 0 for i in args: s += sum(i) return s # print ...

随机推荐

  1. Ubuntu 添加多用户和Samba

    USERNAME="$1" SMBFILE="/etc/samba/smb.conf" if [ $# != 1 ] then echo "使用方: ...

  2. 收藏几个常用的vue自定义组件,抄自 他人,以防丢失

    在 Vue,除了核心功能默认内置的指令 ( v-model 和 v-show ),Vue 也允许注册自定义指令.它的作用价值在于当开发人员在某些场景下需要对普通 DOM 元素进行操作. Vue自定义指 ...

  3. mac_使用Charles抓取Firefox 链接

    1. 首先在Charles 中导出证书,操作为:Help选项 --> SSL Proxying --> 选择第二项 Install Charles Root Certificate 2. ...

  4. 【译】GitHub Copilot Free 在 Visual Studio 中

    可能您还没有听说过,GitHub 刚刚宣布了 Copilot Free(免费版)!好消息是:您现在已经可以在 Visual Studio 中开始使用 Copilot Free 了.它现在已经可用了,我 ...

  5. KES(KingBaseES)集群部署实战

    今天我们将探讨关于KES(KingBaseES)的集群部署方案.作为示例,我们将以读写分离(RWC)集群为例,快速在本地进行部署和安装,并深入了解KES的部署流程.在本章中,我们将采用Windows平 ...

  6. javascript与css3动画学习笔记

    当Html5,css3已渐渐成为主流的时候,我还非常习惯的用js去做一些简单的动画.因为在桌面浏览器上, 并非所有的都支持css3.用户也倒是很奇怪,用户习惯并不是每个用户都可以被培养.总有不少人会觉 ...

  7. Kotlin:【Map集合】集合创建、集合遍历、元素增加

    to本身是一个函数

  8. 再获权威认可!天翼云论文被IEEE/ACM CCGrid收录

    近日,由天翼云弹性网络开拓者团队撰写的<Towards Better QoS and Lower Costs of P4 EIP Gateway at the Edge>论文被The 24 ...

  9. 浅说TCP状态机制

    本文分享自天翼云开发者社区<浅说TCP状态机制>,作者:云云生息 TCP(Transmission Control Protocol)是一种面向连接的.可靠的传输协议,常用于互联网中应用层 ...

  10. Windows下安装和配置Java JDK

    1.下载地址 JDK21 Windows安装版下载地址:https://www.oracle.com/java/technologies/downloads/#jdk21-windows JDK21 ...