谈一谈数组拼接tf.concat()和np.concatenate()的区别
作者:mstar1992 时间:2023-01-19 22:15:36
废话不多说啦,直接看代码吧!
tf.concat
t1 = [[1, 2, 3], [4, 5, 6]]
t2 = [[7, 8, 9], [10, 11, 12]]
tf.concat(0, [t1, t2]) ==> [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]
tf.concat(1, [t1, t2]) ==> [[1, 2, 3, 7, 8, 9], [4, 5, 6, 10, 11, 12]]
# tensor t3 with shape [2, 3]
# tensor t4 with shape [2, 3]
tf.shape(tf.concat(0, [t3, t4])) ==> [4, 3]
tf.shape(tf.concat(1, [t3, t4])) ==> [2, 6]
numpy.concatenate
a = np.array([[1, 2], [3, 4]])
b = np.array([[5, 6]])
np.concatenate((a, b), axis=0)
array([[1, 2],
[3, 4],
[5, 6]])
np.concatenate((a, b.T), axis=1)
array([[1, 2, 5],
[3, 4, 6]])
来源:https://blog.csdn.net/u013713117/article/details/54587555
标签:数组拼接,tf.concat,np.concatenate
0
投稿
猜你喜欢
常用一些Javascript判断函数
2024-05-05 09:23:12
详解SQL Server数据库状态和文件状态
2024-01-26 14:09:28
pandas的Series类型与基本操作详解
2021-03-23 12:06:36
python飞机大战pygame碰撞检测实现方法分析
2023-01-05 18:55:52
非常不错的[JS]Cookie精通之路第1/2页
2023-09-04 04:04:34
python微信跳一跳系列之棋子定位颜色识别
2023-01-16 04:52:49
Python实现读取机器硬件信息的方法示例
2021-02-04 16:28:55
基于Python数据结构之递归与回溯搜索
2022-02-27 01:40:33
Java利用套接字实现应用程序对数据库的访问
2024-01-15 19:37:47
JavaScript动态调整图片尺寸
2009-11-23 12:20:00
mysql数据库锁的产生原因及解决办法
2024-01-20 14:09:46
MySQL判别InnoDB表是独立表空间还是共享表空间的方法详解
2024-01-18 14:23:34
ie7空格的间距要比ie6/firefox/opera的都要大
2008-05-24 16:54:00
Git建立本地仓库并上传到Gitee的详细步骤
2023-03-06 20:45:21
php curl登陆qq后获取用户信息时证书错误
2023-11-15 08:23:39
在Mac中PyCharm配置python Anaconda环境过程图解
2023-10-19 01:22:53
基于ASPJPEG 制作了一个梦寐已久的批量水印工具步骤
2011-02-28 10:39:00
python之tensorflow手把手实例讲解猫狗识别实现
2021-12-26 14:46:11
VTK与Python实现机械臂三维模型可视化详解
2021-11-03 19:36:02
Python如何使用ConfigParser读取配置文件
2023-11-03 03:05:30