【转载】 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 ...
随机推荐
- 1219 Vue项目创建及基础
目录 vue项目 1. 项目创建 cmd创建 可视化创建 2. 项目启动 vue重新构建依赖 pycharm管理vue项目 3. 项目目录介绍 index.html index.js App.vue ...
- keras模块学习之-激活函数(activations)--笔记
本笔记由博客园-圆柱模板 博主整理笔记发布,转载需注明,谢谢合作! 每一个神经网络层都需要一个激活函数,例如一下样例代码: from keras.layers.core import Activati ...
- 【Java】深拷贝和浅拷贝
Java中的对象拷贝(Object Copy)指的是将一个对象的所有属性(成员变量)拷贝到另一个有着相同类类型的对象中去.举例说明:比如,对象A和对象B都属于类S,具有属性a和b.那么对对象A进行拷贝 ...
- git常用命令总结--原创
0.git status 仓库状态1.git add 工作区-->暂存区2.git commit 暂存区-->版本库3.git log 查看日志4.git reset --hard hea ...
- 应该知道的linux命令
常用命令 1.在compose Bar下可以对多个服务器同时进行操作.选择To All Sessions 2. 查看JAVA进程: ps -ef | grep java ps auxf | grep ...
- 模拟赛20181031 雅礼 Wearry 养花 折射 画作
% Day1 Solution % Wearry % Stay determined! 养花 考虑当 kkk 确定的时候如何求答案, 显然对于所有形如 [ak,(a+1)k)[ak, (a+1) ...
- 5.5(OI一本通开始)
一, 第一个程序有错误, 1, 每个语句(每行?0)要有分号
- OFDM为什么要在频域内插后做fftshift
目的:“便于”演算和分析 方法:转换成负频率,得到零中频. 注意:Matlab下标从1开始,数字信号处理下标从0开始,因此以下作图做了转换.
- IDEA设置提示生成序列化ID
背景: 实现Serializable接口的类,没有提示生成序列化ID 解决问题: 1.FIle->Settings->Editor->inspections 2.点击java-> ...
- (二)IDEA使用,快捷键
idea的快捷键设置: idea支持使用其他开发工具的快捷键,可以在此设置: idea 默认的本身的快捷键: 常用快捷键 Ctrl + Alt + s 打开设置选项 Alt + Enter 修复提示 ...