首页 > 其他 > 详细

tf.concat

时间:2020-11-26 22:20:36      阅读:31      评论:0      收藏:0      [点我收藏+]

tf.concat是把多个tensor合并成一个,合并增加行:

import tensorflow as tf
tensor_1 = tf.constant([[1, 2], 
                        [3, 4],
                        [5, 6]] )  # 2*3
tensor_2 = tf.constant([[7, 8],
                        [9, 10],
                        [11, 12]]) # 2*3
tf.concat([tensor_1, tensor_2], axis=0) 

输出:

<tf.Tensor: shape=(6, 2), dtype=int32, numpy=
array([[ 1,  2],
       [ 3,  4],
       [ 5,  6],
       [ 7,  8],
       [ 9, 10],
       [11, 12]], dtype=int32)>

增加列:

tf.concat([tensor_1, tensor_2], axis=1) 

输出:

<tf.Tensor: shape=(3, 4), dtype=int32, numpy=
array([[ 1,  2,  7,  8],
       [ 3,  4,  9, 10],
       [ 5,  6, 11, 12]], dtype=int32)>

tf.concat

原文:https://www.cnblogs.com/oaks/p/14044149.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!