当前位置:网站首页>np.concatenate中axis的理解
np.concatenate中axis的理解
2022-06-13 01:01:00 【思考实践】
官方文档中参数
concatenate(...)
concatenate((a1, a2, ...), axis=0)
Join a sequence of arrays along an existing axis.
Parameters
----------
a1, a2, ... : sequence of array_like
The arrays must have the same shape, except in the dimension
corresponding to `axis` (the first, by default).
axis : int, optional
The axis along which the arrays will be joined. Default is 0.
Return
array.shape,axis=0就是对第一个维度进行操作,
axis=1就是对第2个维度进行操作,
axis=2就是对第3个维度进行操作,以此类推…
所说的第一个维度就是沿着x方向进行拼接,也就是把矩阵和矩阵上下拼接;第二个维度就是沿着y方向进行拼接,也就是把矩阵和矩阵左右拼接;第三个维度就是沿着z方向进行拼接,也就是把矩阵和矩阵合在一起。(x,y方向就是正常的坐标轴方向)
注意: 拼接时候一定要注意维度,就好比axis=0,要进行上下拼接,那么两个矩阵的列数一定要相同;axis=1就是行数相同;axis=2就是行列数均相同。
————————————————
版权声明:本文为CSDN博主「ly_ljs_521」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/ly_ljs_521/article/details/123204684
例子
a = np.array([[1, 2], [3, 4]])
b = np.array([[5, 6]])
np.concatenate((a, b), axis=0) # 这里的axis=0的表示按照行进行合并
array([[1, 2],
[3, 4],
[5, 6]])
a = np.array([[1, 2], [3, 4]])
b = np.array([[5, 6]])
np.concatenate((a, b.T), axis=1) # 这里的axis=1的表示按照列进行合并
array([[1, 2, 5],
[3, 4, 6]])
参考资料
深度学习中的concatenate使用_alxe_made的博客-CSDN博客_concatenate
np.concatenate中axis的理解_ly_ljs_521的博客-CSDN博客_concatenate的axis
边栏推荐
猜你喜欢

生态聚合NFT来袭,Metaverse Ape引领Web 3.0元宇宙新范式革命
![[JS component] custom paging](/img/a7/42082c72ad8f2af1a52e1ab1293790.jpg)
[JS component] custom paging

Kotlin collaboration, the life cycle of a job

The tle4253gs is a monolithic integrated low dropout tracking regulator in a small pg-dso-8 package.

Et5.0 value type generation

Opencv desaturation

论文笔记:STMARL: A Spatio-Temporal Multi-AgentReinforcement Learning Approach for Cooperative Traffic

Canvas random bubbling background

在国企做软件测试工程师是一种什么样的体验:每天过的像打仗一样
![[Latex] 插入圖片](/img/0b/3304aaa03d3fea3ebb93b0348c3131.png)
[Latex] 插入圖片
随机推荐
Jenkins持续集成操作
Undirected graph -- computing the degree of a node in compressed storage
How to choose stocks? Which indicator strategy is reliable? Quantitative analysis and comparison of strategic returns of BBI, MTM, obv, CCI and priceosc indicators
Key point detection data preparation and model design based on u-net Network -- detection model of four key points of industrial components
[JS component] customize the right-click menu
Comparison of disk partition modes (MBR and GPT)
About_ int128
深度学习训练多少轮?迭代多少次?
Three threads print digital demo alternately
3623. Merge two ordered arrays
Binary tree - right view
Kotlin 协程的四种启动模式
HashSet underlying source code
[JS component library] drag sorting component
Android Weather
五篇经典好文,值得一看(2)
深度学习每周期的步数多少合适?
Androi天气
Get preview of precast body
Canvas game lower level 100