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的用法的更多相关文章

  1. tf.concat, tf.stack和tf.unstack的用法

    tf.concat, tf.stack和tf.unstack的用法 tf.concat相当于numpy中的np.concatenate函数,用于将两个张量在某一个维度(axis)合并起来,例如: a ...

  2. TensorFlow tf.app&tf.app.flags用法介绍

    TensorFlow tf.app&tf.app.flags用法介绍 TensorFlow tf.app argparse  tf.app.flags 下面介绍 tf.app.flags.FL ...

  3. 深度学习原理与框架-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 ...

  4. 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 ...

  5. tensorflow 笔记7:tf.concat 和 ops中的array_ops.concat

    用于连接两个矩阵: mn = array_ops.concat([a, d], 1) #  按照第二维度相接,shape1 [m,a] shape2 [m,b] ,concat_done shape ...

  6. 学习TensorFlow的tf.concat使用

    https://www.tensorflow.org/api_docs/python/tf/concat

  7. 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 ...

  8. MySQL中CONCAT()的用法

    MySQL中CONCAT()的用法 在日常开发过程中,特别是在书写接口的时候,经常会遇到字符串拼接的情况,比如在返回图片数据时,数据库里往往存储的是相对路径,而接口里一般是存放绝对地址,这就需要字符串 ...

  9. 【转载】 TensorFlow tf.app&tf.app.flags用法介绍

    作 者:marsggbo 出 处:https://www.cnblogs.com/marsggbo版权声明:署名 - 非商业性使用 - 禁止演绎,协议普通文本 | 协议法律文本. ---------- ...

随机推荐

  1. win10+py3.6+cuda9.0安装pytorch1.1.0

    参考:清华源失效后如何安装pytorch1.01 GPU版本的安装指令为: conda install pytorch torchvision cudatoolkit=9.0 -c pytorch 这 ...

  2. SpringAOP ApectJ 动态代理

    参考链接:https://docs.spring.io/spring/docs/4.3.13.RELEASE/spring-framework-reference/htmlsingle/#aop ht ...

  3. Optional int parameter 'resourceState' is present but cannot be translated into a null value

    错误日志: java.lang.IllegalStateException: Optional int parameter 'resourceState' is present but cannot ...

  4. leetcode 337. 打家劫舍iii

    题目描述: 在上次打劫完一条街道之后和一圈房屋后,小偷又发现了一个新的可行窃的地区.这个地区只有一个入口,我们称之为“根”. 除了“根”之外,每栋房子有且只有一个“父“房子与之相连.一番侦察之后,聪明 ...

  5. vue+elementui项目打包后样式变化问题

    博主刚刚解决了index.html空白问题,刚打开项目页面又发现了样式出现了大问题,样式与开发版本有很大不同,有些样式没有生效.利用搜索引擎,找到了问题所在以及解决办法:main.js中的引入顺序决定 ...

  6. php 对接微信接口 {"errcode":41001,"errmsg":"access_token missing hint

    这里是针对所有token微信都有这种机制 1.token被多次访问无效 访问微信接口->得到token,缓存起来2小时内有效,期间2小时内每次都取缓存即可,不必每次都去微信那边兑换 问题:缓存期 ...

  7. 微信token介绍

    这里的微信token 有以下三种 1.小程序的token  (appid+appsecret=token) 2.一个是第三方平台token(comment_appid+comment_appsecre ...

  8. 防止同一IP多次请求攻击

    防止同一IP多次请求攻击 防止入侵者,通过死循环同一时间批量向服务器请求数据,导致服务器内存开销不断膨胀,最后直接瘫痪. 一. 新增一个spring的拦截器 , 拦截所有请求 <mvc:inte ...

  9. Win10登陆界面卡住,进去后无法打开网络相关的设置,谷歌浏览器无法上网

    今天Win10抽风,进入登录页面输入用户名和密码之后,大约过了10分钟才进入桌面.重启后仍然如此. 经过调查,问题主要出在网络相关模块上,网络无法正常初始化,导致登录一直卡在网络初始化上. 解决方法如 ...

  10. Eclipse4.2juno安装git

    因为项目需要,需要再Eclipse4.2juno上面安装git,试了几次都没有成功,网上搜了下,结合报错发现,Eclipse4.2juno支持的最高版本是git3.2,因此,选选择3.2版本的git安 ...