当前位置:网站首页>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
边栏推荐
- STM32 USB Basics
- Remove duplicates from an ordered array
- Characteristics of transactions - persistence (implementation principle)
- The grass is bearing seeds
- Leetcode-12- integer to Roman numeral (medium)
- [server data recovery] successful cases of data loss recovery during data migration between storage servers
- MySQL异常:com.mysql.jdbc.PacketTooBigException: Packet for query is too large(4223215 > 4194304)
- Four startup modes of kotlin collaboration
- [virtual machine] notes on virtual machine environment problems
- MySQL transaction
猜你喜欢

408 true question - division sequence

.net core 抛异常对性能影响的求证之路

Binary tree - right view

Liu Hui and introduction to nine chapter arithmetic and island arithmetic

Key point detection data preparation and model design based on u-net Network -- detection model of four key points of industrial components

What is the difference between pytorch and tensorflow?

Binary tree -- using hierarchical sequence and middle sequence to determine a tree

Wal mechanism of MySQL

Download nail live playback through packet capturing
![[Latex] 插入圖片](/img/0b/3304aaa03d3fea3ebb93b0348c3131.png)
[Latex] 插入圖片
随机推荐
408 true question - division sequence
Traditional machine learning classification model predicts the rise and fall of stock prices
Wal mechanism of MySQL
Three column simple Typecho theme lanstar/ Blue Star Typecho theme
redis
Bubble sort - alternate sort at both ends
[Latex] 插入图片
Jenkins continuous integration operation
Unity calls alertdialog
Today's sleep quality record 74 points
Pipeline流水线项目构建
[JS] battle chess
Canvas random bubbling background
Leetcode-9-palindromes (simple)
sort
Download nail live playback through packet capturing
How to choose stocks? Which indicator strategy is reliable? Quantitative analysis and comparison of strategic benefits of ASI, VR, arbr, DPO and trix indicators
Et5.0 configuring Excel
What is meebits? A brief explanation
MySQL异常:com.mysql.jdbc.PacketTooBigException: Packet for query is too large(4223215 > 4194304)