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的用法相关推荐

  1. 【TensorFlow】tf.concat的用法

    tf.concat是连接两个矩阵的操作 tf.concat(concat_dim, values, name='concat') 除去name参数用以指定该操作的name,与方法有关的一共两个参数: ...

  2. Tensorflow中的tf.layers.batch_normalization()用法

    使用tf.layers.batch_normalization()需要三步: 在卷积层将激活函数设置为None. 使用batch_normalization. 使用激活函数激活. 需要特别注意的是:在 ...

  3. TensorFlow常用函数tf.where()、tf.gather()、tf.squeeze()详解!!

    1.tf.where() 第一种用法: where(condition)的用法 where(condition, x=None, y=None, name=None)  condition是bool型 ...

  4. tensorflow基础:tf.data.Dataset.from_tensor_slices()

    tf.data.Dataset.from_tensor_slices() 语义解释:from_tensor_slices,从张量的切片读取数据. 工作原理:将输入的张量的第一个维度看做样本的个数,沿其 ...

  5. tensorflow基础:tf.data.Dataset.from_tensor_slices() 与 tf.data.Dataset.from_generator()的异同

    tf.data.Dataset.from_tensor_slices(tensor): -->将tensor沿其第一个维度切片,返回一个含有N个样本的数据集(假设tensor的第一个维度为N). ...

  6. Tensorflow基础:tf.matmul() 和tf.multiply() 的区别

    tf.multiply() 两个矩阵中对应元素各自相乘 格式: tf.multiply(x, y, name=None) 参数: x: 一个类型为:half, float32, float64, ui ...

  7. tensorflow错误记录:tf.concat

    http://blog.csdn.net/zcf1784266476/article/details/71248799

  8. tf.concat()详解

    tensorflow中用来拼接张量的函数tf.concat(),用法: tf.concat([tensor1, tensor2, tensor3,...], axis) 先给出tf源代码中的解释: t ...

  9. tensorflow里面函数记录

    numpy中axis参数说明 https://www.jianshu.com/p/25e3d216e5bd axis=i,即沿着数组第i个下标的变化方向进行操作. 这里我们用numpy.sum(axi ...

最新文章

  1. cocos2dx[3.4](26)——视差节点ParallaxNode
  2. IDEA 中的神奇插件:防沉迷、防猝死...
  3. 网络配置_Linux网络环境配置
  4. 物联网智能网关应用系统的一般设计方法
  5. apache.camel_Apache Camel 2.18发布–包含内容
  6. css划上去变长,Css3如何实现鼠标移上变长特效?(图文+视频)
  7. 基于ZYNQ FPGA实现图像采集存储显示
  8. 源代码管理分析工具 - Source Navigator
  9. Ubuntu gerrit 安装配置
  10. 让java类继承TBase进行序列化
  11. SpringBoot @Async注解的学习
  12. 遥感NDVI估算植被覆盖度
  13. 定时器的用法以及pwm的调速
  14. HTTP头部解释,HTTP头部详细分析,最全HTTP头部信息
  15. 光流传感器 定位精度_基于多传感器的无人机定位和避障技术研究
  16. Kotlin高仿微信-第6篇-主页-我的
  17. 什么叫显示动力学,什么叫隐式动力学分析!
  18. 阿里云ECS部署Docker
  19. Apache DolphinScheduler 在叽里呱啦的实战经验
  20. 24WDC-DC矿用本质安全型电源的设计本安电源开关电源

热门文章

  1. 传真存储转发工作过程
  2. 开学季征文 | 百尺竿头,我们都要更进一步
  3. 【学习笔记】PHP进阶
  4. Visual Studio2022 运行代码时“发生生成错误,是否继续并运行上次的成功生成”
  5. 大一大学计算机论文摘要,大学计算机基础小论文
  6. 反射:获取Class类的三种方法
  7. 【从零学习openCV】IOS7下的人脸检测
  8. Party Lemonade
  9. 一致性哈希算法原理详解
  10. 论文阅读:An Empirical Study of Spatial Attention Mechanisms in Deep Networks