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 ...
随机推荐
- mysql数据库安装、启动及权限设置
1. 安装需安装mysql客户端和服务器端. Centos下,可用命令:yum install mysql安装mysql客户端:使用命令:yum install mysql-server安装mysql ...
- java接口的高级应用
直接上菜 /*接口类*/ public interface MsgListener{ public void afterMsgRecived(String msgData); } /*工具类*/ pu ...
- com.fasterxml.jackson.core.JsonParseException: Unexpected character
com.fasterxml.jackson.core.JsonParseException: Unexpected )): was expecting double-quote to start fi ...
- <LeetCode OJ> 78 / 90 Subsets (I / II)
Given a set of distinct integers, nums, return all possible subsets. Note: Elements in a subset must ...
- js&jquery获取指定table指定行里面的内容
js&jquery获取指定table指定行里面的内容 CreateTime--2018年5月18日11:46:04 Author:Marydon 1.展示 代码展示 <table s ...
- spring AOP编程--AspectJ注解方式
1. AOP 简介 AOP(Aspect-Oriented Programming, 面向切面编程): 是一种新的方法论, 是对传统 OOP(Object-Oriented Programming, ...
- 利用端口映射解决:拥有公网IP有限,内网需要访问因特网
动态端口映射: 内网中的一台电脑要访问新浪网,会向NAT网关发送数据包,包头中包括对方(就是新浪网)IP.端口和本机IP.端口,NAT网关会把本机IP.端口替换成自己的公网IP.一个未使用的端口, ...
- hdu 4494 Teamwork (可行流的最小流)
去年通话邀请赛的B题,当时居然过的那么少...明明是一道非常裸的可行流最小流麽..仅仅要对每种人分别求一下可行最小流加起来就能够了.建图是对每一个点拆点,容量上下届都设为v[i],然后每一个点间能连边 ...
- Centos 开启telnet-service服务
1. 查看linux版本信息: [loong@localhost ~]$ cat /etc/issue CentOS release 5.8 (Final) Kernel \r on an \m 2. ...
- USES_CONVERSION的使用和注意
USES_CONVERSION是用来转换类型的,比如我们很常见的问题: 在Socket编程时候,我们的IP地址从界面上输进去一般都使用CString类型的,可是在SOCKADDR_IN中的inet_a ...