python - TensorFlow:tf.train.batch 中 dequeue_up_to 比 dequeue_many 慢吗?

标签 python machine-learning tensorflow computer-vision deep-learning

source code在 GitHub 上,如果我在 train.batch 中使用 allow_smaller_final_batch=True,则对所有内容使用 dequeue_up_to 而不是 dequeue_many批处理。 dequeue_up_to 是否较慢?即使在 TensorFlow 存储库中搜索后,我也无法找到该源代码。我已经跟踪了 dequeue_manydequeue_up_to 函数,直到这个文件 here但我找不到 gen_data_flow_ops 及其函数,并且在存储库中搜索仅返回 gen_data_flow_ops 导入的结果。为什么会这样?

最佳答案

难以跟踪代码从 Python 代码路径到 C++ 操作是 TensorFlow 操作包装技术的一个不幸后果。一般来说,C++ 实现被命名为 FooBarOp,而 Python 最终在生成的代码中调用 foo_bar。

在本例中gen_data_flow_ops._queue_dequeue_up_to_v2是一个自动生成的Python包装器,用于注册QueueDequeueUpToV2 ,这是 C++ DequeueUpToOp 的别名.

为了回答您原来的问题,队列本身不太可能有任何显着的性能差异(出队的 UpTo 版本仅在队列关闭后执行不同的操作)。然而,启用allow_small_batch将从图中删除一些静态形状信息(批量大小),如果下游操作基于静态形状进行优化,这可能会使下游操作变慢一些。

关于python - TensorFlow:tf.train.batch 中 dequeue_up_to 比 dequeue_many 慢吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42119900/

相关文章:

Python正则表达式查找目录中的最新文件

python - mongoengine中的EmbeddedDocumentField和ReferenceField

machine-learning - 从 mlr 包的重采样函数中获取特定的随机森林变量重要性度量

python - TensorFlow ValueError : The channel dimension of the inputs should be defined. 发现 `None`

machine-learning - TfLearn 混淆矩阵训练在 std::bad_alloc 上终止

python - 张量对于图形分布来说太大 - "InternalError: Message length was negative"

python - 匹配所有未包装到 <a> 标记中的网址

python - 尝试使用txt文件使用来自传感器的数据集实时绘制直方图

Python SkLearn : ValueError: Found input variables with inconsistent numbers samples: [1173, 294]

machine-learning - Flask Web应用程序中的机器学习模型错误