码迷,mamicode.com
首页 > 其他好文 > 详细

tf.concat的用法

时间:2019-09-18 23:26:55      阅读:206      评论:0      收藏:0      [点我收藏+]

标签:code   mamicode   com   就是   维度   tensor   sha   port   其它   



import numpy as np
import tensorflow as tf
sess=tf.Session()
a=np.zeros((1,2,3,4))
b=np.ones((1,2,3,4))
c1 = tf.concat([a, b], axis=-1) # 倒数第一维度增加,其它不变
d1=sess.run(c1)
print(‘d1=‘,d1)
print(‘d1.shape=‘,d1.shape)
c = tf.concat([a, b], axis=-2) #倒数第二维度增加,其它不变
d=sess.run(c)
print(‘d=‘,d)
print(‘d.shape=‘,d.shape)
a1=np.zeros((3,4))
b1=np.ones((3,4))
c2 = tf.concat([a1, b1], axis=-1) # 如果是二维就和axis=1一样,第2维坐标增加,就是行不变,列增加
d2=sess.run(c2)
print(‘d2=‘,d2)
print(‘d2.shape=‘,d2.shape)

 

 

 

技术图片

 

 技术图片

 

tf.concat的用法

标签:code   mamicode   com   就是   维度   tensor   sha   port   其它   

原文地址:https://www.cnblogs.com/tangjunjun/p/11546250.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!