欢迎来到代码驿站!

Python代码

当前位置:首页 > 软件编程 > Python代码

谈一谈数组拼接tf.concat()和np.concatenate()的区别

时间:2022-01-12 08:50:40|栏目:Python代码|点击:

废话不多说啦,直接看代码吧!

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]])

上一篇:windows下Virtualenvwrapper安装教程

栏    目:Python代码

下一篇:numpy创建神经网络框架

本文标题:谈一谈数组拼接tf.concat()和np.concatenate()的区别

本文地址:http://www.codeinn.net/misctech/189897.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有