TensorFlow基础笔记(4) Tensor Transformation
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的更多相关文章
- TensorFlow基础笔记(0) 参考资源学习文档
1 官方文档 https://www.tensorflow.org/api_docs/ 2 极客学院中文文档 http://www.tensorfly.cn/tfdoc/api_docs/python ...
- TensorFlow基础笔记(3) cifar10 分类学习
TensorFlow基础笔记(3) cifar10 分类学习 CIFAR-10 is a common benchmark in machine learning for image recognit ...
- tensorflow+入门笔记︱基本张量tensor理解与tensorflow运行结构
Gokula Krishnan Santhanam认为,大部分深度学习框架都包含以下五个核心组件: 张量(Tensor) 基于张量的各种操作 计算图(Computation Graph) 自动微分(A ...
- TensorFlow基础笔记(0) tensorflow的基本数据类型操作
import numpy as np import tensorflow as tf #build a graph print("build a graph") #生产变量tens ...
- TensorFlow基础笔记(14) 网络模型的保存与恢复_mnist数据实例
http://blog.csdn.net/huachao1001/article/details/78502910 http://blog.csdn.net/u014432647/article/de ...
- TensorFlow基础笔记(11) conv2D函数
#链接:http://www.jianshu.com/p/a70c1d931395 import tensorflow as tf import tensorflow.contrib.slim as ...
- TensorFlow基础笔记(6) 图像风格化实验
参考 http://blog.csdn.net/wspba/article/details/53994649 https://www.ctolib.com/AdaIN-style.html Ackno ...
- TensorFlow基础笔记(1) 数据读取与保存
https://zhuanlan.zhihu.com/p/27238630 WholeFileReader # 我们用一个具体的例子感受tensorflow中的数据读取.如图, # 假设我们在当前文件 ...
- TensorFlow基础笔记(15) 编译TensorFlow.so,提供给C++平台调用
参考 http://blog.csdn.net/rockingdingo/article/details/75452711 https://www.cnblogs.com/hrlnw/p/700764 ...
随机推荐
- 导入exce表格中的数据l到数据库
因为我的项目是JavaWeb的,所有是通过浏览器导入数据库到服务器端的数据库,这里我们采用struts来帮助我们完成. 1:首先定义一个文件上传的jsp页面.把我们的数据先上传到服务器端. <f ...
- Linux Samba安装与使用
一 安装环境: 虚拟机:RedHat 5.4 192.168.75.128 主机环境:WIN7 32bit 192.168.75.1 网络连接方式:NAT 二 安装步骤: 说明: Ø samb ...
- js&jquery 获取select下拉框的值、文本内容、自定义属性
js&jquery 获取select下拉框的值.文本内容.自定义属性 CreationTime--2018年7月2日09点22分 Author:Marydon html <selec ...
- ajax 缓存问题及解决方案
ajax 缓存问题及解决方案 CreationTime--2018年7月25日16点04分 Author:Marydon 1.什么情况下ajax请求会出现缓存? 当请求的路径.参数名.参数值三者都 ...
- Android WiFi直连 双向通信
代码地址如下:http://www.demodashi.com/demo/13965.html 原文地址:https://blog.csdn.net/VNanyesheshou/article/det ...
- MongoDB 日志太大怎么办?
MongoDB的日志增长的非常快,/var所在的空间立即就占满了,即便换到还有一个磁盘分区保存日志.日志还是增长的非常快.磁盘眼看要告磬. 有一个好办法,就是使用旋转日志. MongoDB的旋转日志有 ...
- 关闭危害的端口DOS命令(转载)
rem ipseccmd -w REG -p "HFUT_SECU" -r "Block UDP/137" -f *+0:137:UDP -n BLOCK -x ...
- localStorage使用总结,页面跳转,保存值
例子 <ul id="edit" contenteditable="true"> <li>修改我吧,然后刷新页面看看,^_^</l ...
- ubuntu中rc.local无效
在ubuntu中写了一点iptables规则,但是,竟然iptables竟然无效,经过多方查找问题...眼泪... 终于发现是rc.local竟然没有运行,我晕.仔细检查iptables脚本n遍,没有 ...
- PCI-Express协议传输层读书笔记
http://www.doczj.com/doc/35cb19633169a4517723a3d9-9.html