https://segmentfault.com/a/1190000008793389

抽取

  • tf.slice(input_, begin, size, name=None):按照指定的下标范围抽取连续区域的子集

  • tf.gather(params, indices, validate_indices=None, name=None):按照指定的下标集合从axis=0中抽取子集,适合抽取不连续区域的子集

 begin为下标起始位置,size为获取个数
input = [[[1, 1, 1], [2, 2, 2]],
[[3, 3, 3], [4, 4, 4]],
[[5, 5, 5], [6, 6, 6]]]
tf.slice(input, [1, 0, 0], [1, 1, 3]) ==> [[[3, 3, 3]]]
tf.slice(input, [1, 0, 0], [1, 2, 3]) ==> [[[3, 3, 3],
[4, 4, 4]]]
tf.slice(input, [1, 0, 0], [2, 1, 3]) ==> [[[3, 3, 3]],
[[5, 5, 5]]] tf.gather(input, [0, 2]) ==> [[[1, 1, 1], [2, 2, 2]],
[[5, 5, 5], [6, 6, 6]]]
下面通过图片实例来说明求解过程:
import tensorflow as tf
import numpy as np
input = np.array([[[1, 1, 1], [2, 2, 2]],
[[3, 3, 3], [4, 4, 4]],
[[5, 5, 5], [6, 6, 6]]])
print(input.shape)
print(input)
sess = tf.Session()
out = tf.slice(input, [1, 0, 0], [1, 2, 3])
print ('out:\n',sess.run(out)) 输出:
(3, 2, 3)
[[[1 1 1]
  [2 2 2]]  [[3 3 3]
  [4 4 4]]  [[5 5 5]
  [6 6 6]]]
out:
 [[[3 3 3]
  [4 4 4]]]
维度为 3 * 2 * 3
第0方向维度,竖直方向,维度为3
第1方向维度,竖直方向,维度为2
第2方向维度,水平方向,维度为3
begin = [1, 0, 0]
size = [1, 2, 3]
定位到 input[1,1,2] = 3
  


TensorFlow基础笔记(4) Tensor Transformation的更多相关文章

  1. TensorFlow基础笔记(0) 参考资源学习文档

    1 官方文档 https://www.tensorflow.org/api_docs/ 2 极客学院中文文档 http://www.tensorfly.cn/tfdoc/api_docs/python ...

  2. TensorFlow基础笔记(3) cifar10 分类学习

    TensorFlow基础笔记(3) cifar10 分类学习 CIFAR-10 is a common benchmark in machine learning for image recognit ...

  3. tensorflow+入门笔记︱基本张量tensor理解与tensorflow运行结构

    Gokula Krishnan Santhanam认为,大部分深度学习框架都包含以下五个核心组件: 张量(Tensor) 基于张量的各种操作 计算图(Computation Graph) 自动微分(A ...

  4. TensorFlow基础笔记(0) tensorflow的基本数据类型操作

    import numpy as np import tensorflow as tf #build a graph print("build a graph") #生产变量tens ...

  5. TensorFlow基础笔记(14) 网络模型的保存与恢复_mnist数据实例

    http://blog.csdn.net/huachao1001/article/details/78502910 http://blog.csdn.net/u014432647/article/de ...

  6. TensorFlow基础笔记(11) conv2D函数

    #链接:http://www.jianshu.com/p/a70c1d931395 import tensorflow as tf import tensorflow.contrib.slim as ...

  7. TensorFlow基础笔记(6) 图像风格化实验

    参考 http://blog.csdn.net/wspba/article/details/53994649 https://www.ctolib.com/AdaIN-style.html Ackno ...

  8. TensorFlow基础笔记(1) 数据读取与保存

    https://zhuanlan.zhihu.com/p/27238630 WholeFileReader # 我们用一个具体的例子感受tensorflow中的数据读取.如图, # 假设我们在当前文件 ...

  9. TensorFlow基础笔记(15) 编译TensorFlow.so,提供给C++平台调用

    参考 http://blog.csdn.net/rockingdingo/article/details/75452711 https://www.cnblogs.com/hrlnw/p/700764 ...

随机推荐

  1. QtGui.QProgressBar

    A progress bar is a widget that is used when we process lengthy tasks. It is animated so that the us ...

  2. js Object.is 相等判断

    Object.is使用“Same-value equality”(同值相等)算法进行相等判断.它用来比较两个值是否严格相等,与严格比较运算符(===)的行为基本一致. Object.is('foo', ...

  3. webpack CommonsChunkPlugin 提取公共代码

    1.项目结构 2.部分代码 module.js console.log('module.js'); index文件夹下的index.js require('../module.js'); consol ...

  4. ubuntu server激活即时通讯IM服务 Instant Messaging is not activated on this server

    转自:http://shine-it.net/index.php/topic,16469.msg28364.html ubuntu server 下 odoo激活及时通讯功能im OpenERP IM ...

  5. sqlserver2008 R2中查找未使用过的索引

    转自:http://blog.csdn.net/yangzhawen/article/details/7247393 sqlserver2008 R2中查找未使用过的索引: o.name AS 表名 ...

  6. 【转发】未能加载文件或程序集“Oracle.DataAccess”或它的某一个依赖项。试图加载格式不正确的程序。

     http://www.cnblogs.com/joey0210/archive/2012/09/29/2708420.html   上一篇文章说到了DLL引用问题,主要是说的程序中如果使用过了反射, ...

  7. Windows下Hadoop编程环境配置指南

    刘勇    Email: lyssym@sina.com 本博客记录作者在工作与研究中所经历的点滴,一方面给自己的工作与生活留下印记,另一方面若是能对大家有所帮助,则幸甚至哉矣! 简介 鉴于最近在研究 ...

  8. Adminer - 类似于phpMyAdmin的MySQL管理客户端

    Adminer是一个类似于phpMyAdmin的MySQL管理客户端.整个程序只有一个PHP文件,易于使用和安装.Adminer支持多语言(已自带11种翻译语言文件,可以按自己的需求翻译相应的语言). ...

  9. Ubuntu14.04安装redis-server

    1.update再install操作: sudo apt-get update sudo apt-get install -y redis-server 如果你已经安装了redis,会提示:redis ...

  10. 编码gbk ajax的提交

    客户端