不同维数组之间的numpy加法
创始人
2025-01-09 20:30:16
0

import numpy as np

创建两个不同维度的数组

array1 = np.array([[1, 2, 3], [4, 5, 6]]) # 2x3数组 array2 = np.array([1, 2, 3]) # 1维数组

扩展array2的维度,使其与array1的维度相同

expanded_array2 = np.expand_dims(array2, axis=0)

或者使用reshape方法

expanded_array2 = array2.reshape((1, array2.shape[0]))

对两个数组进行加法运算

result = array1 + expanded_array2

print(result)

输出:

[[2 4 6]

[5 7 9]]

相关内容

热门资讯

透视app!aapoker破解... 透视app!aapoker破解侠是真的吗(透视)ai插件(其实存在有挂)1)aapoker破解侠是真...
辅助透视!aapoker透视插... 辅助透视!aapoker透视插件(透视)透视脚本入口(真是存在有挂)1、实时aapoker透视插件开...
透视攻略!aapoker辅助器... 透视攻略!aapoker辅助器是真的吗(透视)脚本(一贯是有挂)1、aapoker辅助器是真的吗机器...
辅助透视!aapoker辅助工... 辅助透视!aapoker辅助工具安全吗(透视)透视软件(其实是真的有挂)1、很好的工具软件,可以解锁...
透视存在!aapoker发牌逻... 透视存在!aapoker发牌逻辑(透视)透视脚本(果然存在有挂);1、进入到aapoker发牌逻辑黑...
透视总结!aapoker ai... 透视总结!aapoker ai插件(透视)辅助插件工具(切实存在有挂)1、点击下载安装,aapoke...
透视智能ai!aa poker... 透视智能ai!aa poker辅助(透视)免费透视脚本(本来真的有挂);1、金币登录送、破产送、升级...
透视黑科技!aapoker怎么... 透视黑科技!aapoker怎么设置抽水(透视)真的假的(切实是真的有挂)1、每一步都需要思考,不同水...
透视挂透视!aapoker发牌... 透视挂透视!aapoker发牌逻辑(透视)真的假的(切实存在有挂)1)aapoker发牌逻辑辅助挂:...
透视肯定!aapoker脚本怎... 透视肯定!aapoker脚本怎么用(透视)插件下载(其实是有挂)1、aapoker脚本怎么用透视辅助...