TensorFlow 介绍 tf.concat 的使用方法
来源:互联网 发布:视差js原理 编辑:程序博客网 时间:2024/06/05 13:34
tf.concat是连接两个矩阵的操作
tf.concat(concat_dim, values, name='concat')
除去name参数用以指定该操作的name,与方法有关的一共两个参数:第一个参数concat_dim:必须是一个数,表明在哪一维上连接
如果
concat_dim
是0,那么在某一个shape的第一个维度上连,对应到实际,就是叠放到列上
- 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]]
concat_dim
是1,那么在某一个shape的第二个维度上连
- t1 = [[1, 2, 3], [4, 5, 6]]
- t2 = [[7, 8, 9], [10, 11, 12]]
- tf.concat(1, [t1, t2]) ==> [[1, 2, 3, 7, 8, 9], [4, 5, 6, 10, 11, 12
如果有更高维,最后连接的依然是指定那个维:
values[i].shape = [D0, D1, ... Dconcat_dim(i), ...Dn]连接后就是:
[D0, D1, ... Rconcat_dim, ...Dn]
- # 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]
第二个参数values:就是两个或者一组待连接的tensor了
这里要注意的是:如果是两个向量,它们是无法调用
- tf.concat(1, [t1, t2])
如果要连,必须要调用tf.expand_dims来扩维:
- t1=tf.constant([1,2,3])
- t2=tf.constant([4,5,6])
- #concated = tf.concat(1, [t1,t2])这样会报错
- t1=tf.expand_dims(tf.constant([1,2,3]),1)
- t2=tf.expand_dims(tf.constant([4,5,6]),1)
- concated = tf.concat(1, [t1,t2])#这样就是正确的
阅读全文
0 0
- TensorFlow 介绍 tf.concat 的使用方法
- 【TensorFlow】tf.concat的用法
- 【TensorFlow】tf.concat的用法
- tensorflow tf.concat操作
- 【TensorFlow】tf.concat
- 【Tensorflow】tf.concat函数
- tensorflow API: tf.concat
- tensorflow错误记录:tf.concat
- tensorflow错误记录:tf.concat
- tensorflow 中tf.concat()用法
- tensorflow错误记录:tf.concat
- tensorflow的tf.equal()函数的使用方法
- tensorflow的tf.reduce_mean()函数的使用方法
- tf.concat的用法
- tf.concat的用法
- tf.concat的用法
- Tensorflow API 学习(1)-tf.concat()
- TensorFlow 介绍 tf.nn.softmax_cross_entropy_with_logits 的用法
- HTML-超文本标记语言
- 行为型模式之策略模式实现
- Oracle with as使用小节
- 卢俊卿欢迎荷兰前首相科克夫妇访问天九集团
- Linux SoftEther VPN Client 使用说明
- TensorFlow 介绍 tf.concat 的使用方法
- document.write设置样式
- 程序员必知之前端演进史
- android中textview文本滚动效果
- 【微信小程序开发】来看看,那些年我们踩过的坑~
- AffinityBasedMattingToolbox
- chocolatey软件包管理器
- matplotlib 配色
- MySQL使用UDF调用shell脚本