【转载】 tf.train.slice_input_producer()和tf.train.batch()
原文地址:
https://www.jianshu.com/p/8ba9cfc738c2
------------------------------------------------------------------------------------------------
1. tf.train.slice_input_producer 函数,一种模型数据的排队输入方法。
tf.train.slice_input_producer(
tensor_list,
num_epochs=None,
shuffle=True,
seed=None,
capacity=32,
shared_name=None,
name=None
)
其参量为:
Args:
tensor_list: A list of Tensor objects.
Every Tensor in tensor_list must have the same size in the first dimension. # 循环Queue输入次数
num_epochs: An integer (optional).
If specified, slice_input_producer produces each slice num_epochs times before generating an OutOfRange error.
If not specified, slice_input_producer can cycle through the slices an unlimited number of times.
shuffle: Boolean. If true, the integers are randomly shuffled within each epoch.
seed: An integer (optional). Seed used if shuffle == True. # Queue的容量
capacity: An integer. Sets the queue capacity. shared_name: (optional). If set, this queue will be shared under the given name across multiple sessions.
name: A name for the operations (optional).
相关代码实例:
# 生成包含输入和目标图片地址名的list
input_files = [os.path.join(dirname, 'input', f) for f in flist]
output_files = [os.path.join(dirname, 'output', f) for f in flist] # 内部自动转换为Constant String的Tensor,并排队进入队列
input_queue, output_queue = tf.train.slice_input_producer(
[input_files, output_files], shuffle=self.shuffle,
seed=0123, num_epochs=self.num_epochs) # tf.train.slice_input_producer()每次取一对【输入-目标】对,交给ReadFile这
# 个Op
input_file = tf.read_file(input_queue)
output_file = tf.read_file(output_queue) # 生成RGB格式的图像tensor
im_input = tf.image.decode_jpeg(input_file, channels=3)
im_output = tf.image.decode_jpeg(output_file, channels=3)
2. tf.train.batch()函数
tf.train.batch(
tensors,
batch_size,
num_threads=1,
capacity=32,
enqueue_many=False,
shapes=None,
dynamic_pad=False,
allow_smaller_final_batch=False,
shared_name=None,
name=None
)
其参量为:
Args:
tensors: The list or dictionary of tensors to enqueue.
batch_size: The new batch size pulled from the queue.
num_threads: The number of threads enqueuing tensors. The batching will be nondeterministic if num_threads > 1.
capacity: An integer. The maximum number of elements in the queue. #进行shuffle的输入是否为单个tensor
enqueue_many: Whether each tensor in tensors is a single example. shapes: (Optional) The shapes for each example. Defaults to the inferred shapes for tensors. dynamic_pad: Boolean.
Allow variable dimensions in input shapes.
The given dimensions are padded upon dequeue so that tensors within a batch have the same shapes. allow_smaller_final_batch: (Optional) Boolean.
If True, allow the final batch to be smaller if there are insufficient items left in the queue. shared_name: (Optional).
If set, this queue will be shared under the given name across multiple sessions. name: (Optional) A name for the operations.
相关代码实例
samples = tf.train.batch(
sample,
batch_size=self.batch_size,
num_threads=self.nthreads,
capacity=self.capacity)
【转载】 tf.train.slice_input_producer()和tf.train.batch()的更多相关文章
- 【转载】 tensorflow中 tf.train.slice_input_producer 和 tf.train.batch 函数
原文地址: https://blog.csdn.net/dcrmg/article/details/79776876 ----------------------------------------- ...
- tensorflow数据读取机制tf.train.slice_input_producer 和 tf.train.batch 函数
tensorflow中为了充分利用GPU,减少GPU等待数据的空闲时间,使用了两个线程分别执行数据读入和数据计算. 具体来说就是使用一个线程源源不断的将硬盘中的图片数据读入到一个内存队列中,另一个线程 ...
- tensorflow中 tf.train.slice_input_producer 和 tf.train.batch 函数(转)
tensorflow数据读取机制 tensorflow中为了充分利用GPU,减少GPU等待数据的空闲时间,使用了两个线程分别执行数据读入和数据计算. 具体来说就是使用一个线程源源不断的将硬盘中的图片数 ...
- tensorflow中 tf.train.slice_input_producer 和 tf.train.batch 函数
tensorflow数据读取机制 tensorflow中为了充分利用GPU,减少GPU等待数据的空闲时间,使用了两个线程分别执行数据读入和数据计算. 具体来说就是使用一个线程源源不断的将硬盘中的图片数 ...
- tf.train.slice_input_producer()
tf.train.slice_input_producer处理的是来源tensor的数据 转载自:https://blog.csdn.net/dcrmg/article/details/7977687 ...
- tensorflow|tf.train.slice_input_producer|tf.train.Coordinator|tf.train.start_queue_runners
#### ''' tf.train.slice_input_producer :定义样本放入文件名队列的方式[迭代次数,是否乱序],但此时文件名队列还没有真正写入数据 slice_input_prod ...
- tfsenflow队列|tf.train.slice_input_producer|tf.train.Coordinator|tf.train.start_queue_runners
#### ''' tf.train.slice_input_producer :定义样本放入文件名队列的方式[迭代次数,是否乱序],但此时文件名队列还没有真正写入数据 slice_input_pr ...
- 深度学习原理与框架-图像补全(原理与代码) 1.tf.nn.moments(求平均值和标准差) 2.tf.control_dependencies(先执行内部操作) 3.tf.cond(判别执行前或后函数) 4.tf.nn.atrous_conv2d 5.tf.nn.conv2d_transpose(反卷积) 7.tf.train.get_checkpoint_state(判断sess是否存在
1. tf.nn.moments(x, axes=[0, 1, 2]) # 对前三个维度求平均值和标准差,结果为最后一个维度,即对每个feature_map求平均值和标准差 参数说明:x为输入的fe ...
- tensorflow 的 Batch Normalization 实现(tf.nn.moments、tf.nn.batch_normalization)
tensorflow 在实现 Batch Normalization(各个网络层输出的归一化)时,主要用到以下两个 api: tf.nn.moments(x, axes, name=None, kee ...
随机推荐
- 开源项目阅读笔记--appium+adb
git上搜了几个platform的代码,有一个项目给我感触挺深的. https://github.com/ThomasHansson/Appium-cross-platform-example/tre ...
- windows 使用SVN命令
在不用安装TortoiseSVN客户端的情况,大家可以再http://subversion.apache.org/packages.html#windows 找到windows下的svn客户端工具.选 ...
- oracle数据库创建表且主键自增
唠叨几句:几年前的知识忘却了,整理一下笔记,提供一下方便 1.创建数据库表 设置主键 create table users( userid number(10) primary key, /*主键,自 ...
- SPOJ - BALNUM - Balanced Numbers(数位DP)
链接: https://vjudge.net/problem/SPOJ-BALNUM 题意: Balanced numbers have been used by mathematicians for ...
- HTML 010 radio
Struts2单选按钮标签s:radio的使用及其设置默认值 转载atom168 发布于2014-12-01 15:40:59 阅读数 519 收藏 展开 首先在页面中引入struts标签库: &l ...
- PHP 鸟哥:我也曾经是“不适合”编程的人
网名:雪候鸟,大家尊称鸟哥,惠新宸 @Laruence, 是国内最有影响力的 PHP 技术专家,PHP 开发组核心成员,PECL 开发者,Zend 公司外聘顾问.他曾供职于雅虎,百度,现在新浪微博任平 ...
- 码农,就要做有范儿的geek【网摘】
摘要: “我是个geek,圈子里都称呼我为xx,我周一到周五亲自写写代码,指导指导新人,周末参加圈子的活动,跟别人分享一下我的经验.至于未来嘛,还没想过,反正自己技术水平在这了,呵呵,扎克伯格当年不也 ...
- python 路径引用问题
文件结构 入口文件· 将当前文件的父级,加入搜索目录里面 import sys import os current_dir = os.path.abspath(os.path.dirname(__fi ...
- 2019暑期金华集训 Day7 动态规划
自闭集训 Day7 动态规划 LOJ6395 首先发现这个树的形态没啥用,只需要保证度数之和是\(2n-2\)且度数大于0即可. 然后设\(dp_{i,j}\)表示前\(i\)个点用了\(j\)个度数 ...
- Multi-Temporal SAR Data Large-Scale Crop Mapping Based on U-Net Model(利用U-net对多时相SAR影像获得作物图)
对哨兵1号的多时相双极化SAR数据进行预处理,得到18个日期的VV和VH共36景影像,通过ANOVA和JM距离分析,选其中ANOVA得到的F值最高的6景影像.真值用LC8数据和地面调查,目视解译得到标 ...