concatenate

In [33]: a = np.random.randint(2, 9, (2, 3, 5))                                                                                                                                                             

In [34]: b = np.random.uniform(2, 3, 5)                                                                                                                                                                     

In [35]: a.shape                                                                                                                                                                                            
Out[35]: (2, 3, 5)

In [36]: b.shape                                                                                                                                                                                            
Out[36]: (5,)

In [37]: b = np.random.uniform(2, 6, (2, 3, 5))                                                                                                                                                             

In [38]: a.shape                                                                                                                                                                                            
Out[38]: (2, 3, 5)

In [39]: b.shape                                                                                                                                                                                            
Out[39]: (2, 3, 5)

In [40]: concat_axis_0 = np.concatenate([a, b], axis=0) #0轴堆叠, 其它轴的shape不变                                                                                                                        

In [41]: concat_axis_0.shape                                                                                                                                                                                
Out[41]: (4, 3, 5)

In [42]: concat_axis_1 = np.concatenate([a, b], axis=1) #1轴堆叠, 其它轴的shape不变                                                                                                                        

In [43]: concat_axis_1.shape                                                                                                                                                                                
Out[43]: (2, 6, 5)

In [44]: concat_axis_2 = np.concatenate([a, b], axis=2) #2轴堆叠, 其它轴的shape不变                                                                                                                        

In [45]: concat_axis_2.shape                                                                                                                                                                                
Out[45]: (2, 3, 10)

In [46]: concat_axis_2 = np.concatenate([a, b], axis=-1) #2轴堆叠, 其它轴的shape不变                                                                                                                       

In [47]: concat_axis_2.shape                                                                                                                                                                                
Out[47]: (2, 3, 10)

torch.cat

pd.concat
https://blog.youkuaiyun.com/leviopku/article/details/82380710

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值