【TensorFlow基础函数】tf.concat的用法
tf.concat 的用法
TF官方的文档
tf.concat(values,axis,name='concat'
)
连接多个Tensor的操作
values 多个Tensor
axis是哪个纬度
0 代表第一纬度
1 代表第二纬度
2 代表第三纬度
n 代表第n+1纬度
案例:
t1 = [[[1, 2, 3], [4, 5, 6]],[[7, 8, 9], [10, 11, 12]]]t2 = [[[12, 13, 14], [15,16, 17]],[[18, 19, 20], [21, 22, 23]]]t4 = [[[24, 25, 26], [27,28, 29]],[[30, 31, 32], [33, 34, 35]]]sess = tf.InteractiveSession()t3 = tf.concat([t1, t2, t4], 1)
结果:
[[[ 1 2 3]
[ 4 5 6]
[12 13 14]
[15 16 17]
[24 25 26]
[27 28 29]]
[[ 7 8 9]
[10 11 12]
[18 19 20]
[21 22 23]
[30 31 32]
[33 34 35]]]
t1 = [[[1, 2, 3], [4, 5, 6]],[[7, 8, 9], [10, 11, 12]]]t2 = [[[12, 13, 14], [15,16, 17]],[[18, 19, 20], [21, 22, 23]]]t4 = [[[24, 25, 26], [27,28, 29]],[[30, 31, 32], [33, 34, 35]]]sess = tf.InteractiveSession()t3 = tf.concat([t1, t2, t4], 2)
结果
[[[ 1 2 3 12 13 14 24 25 26]
[ 4 5 6 15 16 17 27 28 29]]
[[ 7 8 9 18 19 20 30 31 32]
[10 11 12 21 22 23 33 34 35]]]
当纬度不能匹配的时候,会出现异常。比如说一纬张量 vector
t4 = [1,2,3,4]t5 = [5,6,7,8]t6 = tf.concat([t4, t5],1)print sess.run(t6)
Shape must be at least rank 2 but is rank 1 for ‘concat_2’ (op: ‘ConcatV2’) with input shapes: [4], [4], [] and with computed input tensors: input[2] = <1>.
【TensorFlow基础函数】tf.concat的用法相关推荐
- 【TensorFlow】tf.concat的用法
tf.concat是连接两个矩阵的操作 tf.concat(concat_dim, values, name='concat') 除去name参数用以指定该操作的name,与方法有关的一共两个参数: ...
- Tensorflow中的tf.layers.batch_normalization()用法
使用tf.layers.batch_normalization()需要三步: 在卷积层将激活函数设置为None. 使用batch_normalization. 使用激活函数激活. 需要特别注意的是:在 ...
- TensorFlow常用函数tf.where()、tf.gather()、tf.squeeze()详解!!
1.tf.where() 第一种用法: where(condition)的用法 where(condition, x=None, y=None, name=None) condition是bool型 ...
- tensorflow基础:tf.data.Dataset.from_tensor_slices()
tf.data.Dataset.from_tensor_slices() 语义解释:from_tensor_slices,从张量的切片读取数据. 工作原理:将输入的张量的第一个维度看做样本的个数,沿其 ...
- tensorflow基础:tf.data.Dataset.from_tensor_slices() 与 tf.data.Dataset.from_generator()的异同
tf.data.Dataset.from_tensor_slices(tensor): -->将tensor沿其第一个维度切片,返回一个含有N个样本的数据集(假设tensor的第一个维度为N). ...
- Tensorflow基础:tf.matmul() 和tf.multiply() 的区别
tf.multiply() 两个矩阵中对应元素各自相乘 格式: tf.multiply(x, y, name=None) 参数: x: 一个类型为:half, float32, float64, ui ...
- tensorflow错误记录:tf.concat
http://blog.csdn.net/zcf1784266476/article/details/71248799
- tf.concat()详解
tensorflow中用来拼接张量的函数tf.concat(),用法: tf.concat([tensor1, tensor2, tensor3,...], axis) 先给出tf源代码中的解释: t ...
- tensorflow里面函数记录
numpy中axis参数说明 https://www.jianshu.com/p/25e3d216e5bd axis=i,即沿着数组第i个下标的变化方向进行操作. 这里我们用numpy.sum(axi ...
最新文章
- cocos2dx[3.4](26)——视差节点ParallaxNode
- IDEA 中的神奇插件:防沉迷、防猝死...
- 网络配置_Linux网络环境配置
- 物联网智能网关应用系统的一般设计方法
- apache.camel_Apache Camel 2.18发布–包含内容
- css划上去变长,Css3如何实现鼠标移上变长特效?(图文+视频)
- 基于ZYNQ FPGA实现图像采集存储显示
- 源代码管理分析工具 - Source Navigator
- Ubuntu gerrit 安装配置
- 让java类继承TBase进行序列化
- SpringBoot @Async注解的学习
- 遥感NDVI估算植被覆盖度
- 定时器的用法以及pwm的调速
- HTTP头部解释,HTTP头部详细分析,最全HTTP头部信息
- 光流传感器 定位精度_基于多传感器的无人机定位和避障技术研究
- Kotlin高仿微信-第6篇-主页-我的
- 什么叫显示动力学,什么叫隐式动力学分析!
- 阿里云ECS部署Docker
- Apache DolphinScheduler 在叽里呱啦的实战经验
- 24WDC-DC矿用本质安全型电源的设计本安电源开关电源