文档章节

ML - tf.cifar10_input.py

e_s
 e_s
发布于 2017/05/08 11:25
字数 391
阅读 5
收藏 0

Some places to notice:

In method read_cifar10(filename_queue);

1. tf.train.string_input_producer(filenames);

    Explain: where 'filenames' is the <list> contains all the names of the binary data batch files.

    Output: a filename queue which can work with <tf.FixedLengthRecordReader>.

--- --- --- --- --- ---

2. tf.FixedLengthRecordReader(record_bytes=record_bytes);

    Explain: where 'record_bytes' is the number of bytes of one single record.

    Output: a <reader> object which can invoke <reader>.read(<filename_queue>).

    Appendix: <reader>.read(<filename_queue>); --output of the method is a <[key, value]> record, where 'key' is a <string> represents the record, 'value' is the content of the record read from <filename_queue> in <string> form. Before 'value' being used, it needs to be converted into <vector of uint8> by 'tf.decode_raw(value, tf.uint8)'. 

--- --- --- --- --- ---

3. tf.slice(record_bytes, [0], [label_bytes]);

    Explain: where 'record_bytes' is now having been transformed to tf.uint8 by 'tf.decode_raw(value, <format>)'. It's a 1-dimensional vector with :

    1) 'record_bytes[0]' as the label of this record which indicates which class it belongs to.

    2)  'record_bytes[1:image_bytes+1]' as the content of the image becomes flattened into a vector.

    parameter '[0]' decides where the slice begins, it's a <list> instead of a number because sometimes the slice needs to operate on multiple-dimensional array. for example the starting point is at 2nd row&4th column, the parameter is [1,3].

    parameter '[label_bytes]' decides the length of the content from the starting point needs to be sliced. '[label_bytes]' is also a <list> instead of a number because the slice piece can also be a multiple-dimensional content. for example,

    #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,2,3]);  ==> output: [ [[3,3,3],[4,4,4]] ]

    #tf.slice(input, [1,0,0], [2,1,3]);  ==> output: [ [[3,3,3]] , [[5,5,5]] ]

--- --- --- --- --- ---

4. tf.cast(tf.slice(record_bytes, [0], [label_bytes]), tf.int32)

    Explain: convert the output of 'tf.slice()' to <tf.int32>

    Output: the converted output of 'tf.slice()'

--- --- --- --- --- ---

5. tf.reshape(tf.slice(record_bytes, [label_bytes], [image_bytes]), [result.depth, result.height, result.width])

    Explain: tf.reshape(<Tensor> tensor, <list> shape);

    Output: input parameter 'tensor' changed to shape of input parameter 'shape'.

--- --- --- --- --- ---

6. tf.transpose(depth_major, [1,2,0]);

    Explain: switch the dimension of the input tensor 'depth_major' from original order to the new order specified in the second input parameter.

    Output: for example,

    #depth_major = [ [[1,2,3],[4,5,6]],

                                 [[7,8,9],[10,11,12]],

                                 [13,14,15],[16,17,18]] 

    #tf.transpose(depth_major,[1,2,0]);

    First, since the shape of 'depth_major' is [3,2,3], by input parameter '[1,2,0]', the output's shape is [2,3,3]. Then we reconstruct the array to a new one of shape [2,3,3],

    [ [[1,7,13],[2,8,14],[3,9,15]],

      [[4,10,16],[5,11,17],[6,12,18]] ]

© 著作权归作者所有

上一篇: Git learning
e_s

e_s

粉丝 0
博文 58
码字总数 24581
作品 0
澳门
程序员
私信 提问
java调用python方法的库jython介绍及使用实例

一、Jython 简介 Jython是一种完整的语言,而不是一个Java翻译器或仅仅是一个Python编译器,它是一个Python语言在Java中的完全实现。Jython也有很多从CPython中继承的模块库。最有趣的事情是...

孟飞阳
2016/07/12
3K
0
tf.transpose 直观感受

tensorflow cifar10的cifar10input.py中readcifar10()最后有一个转置语句 result.uint8image = tf.transpose(depth_major, [1, 2, 0]) 用以下语句直观感受一下 import as import numpy as ......

隐士2018
2018/07/29
0
0
python windows下批量修改文件名

经常会下载一些资料和学习视频,往往这些资料名称很多,想批量修改又很不方便,刚好用python写一个修改文件名的小程序。 windows下安装python这个就不多说了,直接下载安装程序安装即可。htt...

shenfly231
2017/04/14
0
0
在java中调用python方法

1、http://sourceforge.net/projects/jython/下载jython包,把其中的jython.jar添加到工程目录 示例: 1、摘自:http://blog.csdn.net/anbo724/article/details/6608632 1.在java类中直接执行......

u0mo5
2014/10/18
0
0
MultiNet学习——KittiBox training processing

KittiBox training processing KittiBox training processing 源码 Box (Detection) training的网络框架 preparation 未设置的系统变量采用了默认值 预定义flags ‘name’ : None ‘project......

Hanging_Gardens
2017/05/17
0
0

没有更多内容

加载失败,请刷新页面

加载更多

OSChina 周日乱弹 —— 我,小小编辑,食人族酋长

Osc乱弹歌单(2019)请戳(这里) 【今日歌曲】 @宇辰OSC :分享娃娃的单曲《飘洋过海来看你》: #今日歌曲推荐# 《飘洋过海来看你》- 娃娃 手机党少年们想听歌,请使劲儿戳(这里) @宇辰OSC...

小小编辑
50分钟前
114
7
spring cloud

一、从面试题入手 1.1、什么事微服务 1.2、微服务之间如何独立通讯的 1.3、springCloud和Dubbo有哪些区别 1.通信机制:DUbbo基于RPC远程过程调用;微服务cloud基于http restFUL API 1.4、spr...

榴莲黑芝麻糊
今天
2
0
Executor线程池原理与源码解读

线程池为线程生命周期的开销和资源不足问题提供了解决方 案。通过对多个任务重用线程,线程创建的开销被分摊到了多个任务上。 线程实现方式 Thread、Runnable、Callable //实现Runnable接口的...

小强的进阶之路
昨天
6
0
maven 环境隔离

解决问题 即 在 resource 文件夹下面 ,新增对应的资源配置文件夹,对应 开发,测试,生产的不同的配置内容 <resources> <resource> <directory>src/main/resources.${deplo......

之渊
昨天
8
0
详解箭头函数和普通函数的区别以及箭头函数的注意事项、不适用场景

箭头函数是ES6的API,相信很多人都知道,因为其语法上相对于普通函数更简洁,深受大家的喜爱。就是这种我们日常开发中一直在使用的API,大部分同学却对它的了解程度还是不够深... 普通函数和...

OBKoro1
昨天
7
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部