tf.concat()
转载自:https://blog.csdn.net/appleml/article/details/71023039
https://www.cnblogs.com/mdumpling/p/8053474.html
tf.concat(concat_dim, values, name='concat')
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]]
tf.concat(1, [t1, t2]) ==> [[1, 2, 3, 7, 8, 9], [4, 5, 6, 10, 11, 12]]
tf.shape(tf.concat(0, [t3, t4])) ==> [4, 3]
tf.shape(tf.concat(1, [t3, t4])) ==> [2, 6]
一维拼接:
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])#这样就是正确的
如果想沿着tensor新轴连接打包,则tf.concat(axis, [tf.expand_dims(t, axis) for t in tensors]),等价于tf.pack(tensors, axis=axis),tf.pack改名为tf.stack了
tf.concat()的更多相关文章
- 深度学习原理与框架-Alexnet(迁移学习代码) 1.sys.argv[1:](控制台输入的参数获取第二个参数开始) 2.tf.split(对数据进行切分操作) 3.tf.concat(对数据进行合并操作) 4.tf.variable_scope(指定w的使用范围) 5.tf.get_variable(构造和获得参数) 6.np.load(加载.npy文件)
1. sys.argv[1:] # 在控制台进行参数的输入时,只使用第二个参数以后的数据 参数说明:控制台的输入:python test.py what, 使用sys.argv[1:],那么将获得w ...
- tensorflow报错error,tf.concat Expected int32, got list containing Tensors of type '_Message' instead
参考:https://stackoverflow.com/questions/41813665/tensorflow-slim-typeerror-expected-int32-got-list-co ...
- tensorflow 笔记7:tf.concat 和 ops中的array_ops.concat
用于连接两个矩阵: mn = array_ops.concat([a, d], 1) # 按照第二维度相接,shape1 [m,a] shape2 [m,b] ,concat_done shape ...
- tf.concat, tf.stack和tf.unstack的用法
tf.concat, tf.stack和tf.unstack的用法 tf.concat相当于numpy中的np.concatenate函数,用于将两个张量在某一个维度(axis)合并起来,例如: a ...
- 学习TensorFlow的tf.concat使用
https://www.tensorflow.org/api_docs/python/tf/concat
- tensorflow 基本函数(1.tf.split, 2.tf.concat,3.tf.squeeze, 4.tf.less_equal, 5.tf.where, 6.tf.gather, 7.tf.cast, 8.tf.expand_dims, 9.tf.argmax, 10.tf.reshape, 11.tf.stack, 12tf.less, 13.tf.boolean_mask
1. tf.split(3, group, input) # 拆分函数 3 表示的是在第三个维度上, group表示拆分的次数, input 表示输入的值 import tensorflow ...
- tf.concat的用法
import numpy as npimport tensorflow as tfsess=tf.Session()a=np.zeros((1,2,3,4))b=np.ones((1,2,3,4))c ...
- tf.concat( )和tf.stack( )
相同点:都是组合重构数据. 不同点:concat()不改变维数,而stack改变了维数(待定!!!) tf.concat是连接两个矩阵的操作,请注意API版本更改问题,相应参数也发生改变,具体查看AP ...
- tf.concat,连接矩阵
tf.concat(concat_dim, values, name='concat') concat_dim需要连接的矩阵的维度, values需要连接的两个矩阵. a=[[1,2,3],[7,8, ...
随机推荐
- 第一份Markdown。。。。。菜鸟给跪了
#First Markdown ##Hello World ###Ahaha - Python - Ruby - C++ - Haskell - C - Java 1. C 2. C++ 3. C# ...
- bzoj1579 道路升级
Description 每天,农夫John需要经过一些道路去检查牛棚N里面的牛. 农场上有M(1<=M<=50,000)条双向泥土道路,编号为1..M. 道路i连接牛棚P1_i和P2_i ...
- JavaScript学习之setTimeout
<JavaScript权威指南>第四版中说“window对象方法setTimeout()用来安排一个JavaScript的代码段在将来的某个指定时间运行”. setTimeout(foo, ...
- 登录注册beta版
注册 login_count = 0 username_inp = input('请输入用户名:') while login_count < 3: pwd_inp = input('请输入密码: ...
- 国内 PHP Composer 镜像列表(2019-07-07)
目录 国内 PHP Composer 镜像列表 Composer 是什么? 镜像列表 配置镜像 本文历史 参考 国内 PHP Composer 镜像列表 Composer 是什么? Composer ...
- Vue CLI图形化创建项目
- Python基础:12函数细节
一:返回值 当没有显式地返回元素时,Python 会返回一个None.如果函数返回多个对象,python 把他们聚集起来并以一个元组返回. 二:创建函数 1:强烈推荐,在函数体之前,编写函数的文档字符 ...
- @atcoder - AGC036E@ ABC String
目录 @description@ @solution@ @accepted code@ @details@ @description@ 给定一个仅由 A, B, C 组成的字符串 S. 求 S 的一个 ...
- PHPExcel 设置表格边框
//设置单元格边框 $style_array = array( 'borders' => array( 'allborders' => array( 'style' => \PHPE ...
- 洛谷P1616 疯狂的采药
//完全背包 #include<bits/stdc++.h> using namespace std; ; ; int n,m,v[maxn],w[maxn],f[maxv]; int m ...