python - tf.train.shuffle_batch_join 和 tf.train.shuffle_batch 之间的区别

标签 python python-3.x tensorflow machine-learning pipeline

查看两个带有参数的函数签名

tf.train.shuffle_batch_join(
tensors_list,
batch_size,
capacity,
min_after_dequeue,
seed=None,
enqueue_many=False,
shapes=None,
allow_smaller_final_batch=False,
shared_name=None,
name=None
)

tf.train.shuffle_batch(
tensors,
batch_size,
capacity,
min_after_dequeue,
num_threads=1,
seed=None,
enqueue_many=False,
shapes=None,
allow_smaller_final_batch=False,
shared_name=None,
name=None
)

参数之间唯一的区别是 num_threads 直观地表示 tf.train.shuffle_batch 可以用多个线程或进程处理,除此之外,它们似乎做几乎相同的工作。

我想知道除了批处理的多重处理之外,是否存在根本的区别,人们可能会选择一个而不是另一个。

最佳答案

引用自 shuffle_batch_join TF 文档:

The tensors_list argument is a list of tuples of tensors, or a list of dictionaries of tensors. Each element in the list is treated similarly to the tensors argument of tf.train.shuffle_batch().

基本上,shuffle_batch_join 期望:

  • 接收张量列表
  • 对列表的每个成员执行 shuffle_batch
  • 返回与 tensors_list[i] 具有相同数量和类型的张量列表。

请注意,如果您使用 shuffle_batch_join :

len(tensors_list) threads will be started, with thread i enqueuing the tensors from tensors_list[i]. tensors_list[i1][j] must match tensors_list[i2][j] in type and shape, except in the first dimension if enqueue_many is true.

Here is a link to the doc.

关于python - tf.train.shuffle_batch_join 和 tf.train.shuffle_batch 之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51276877/

相关文章:

python - 更改列表中的特定索引

tensorflow - 将 Lasagne BatchNormLayer 转换为 Keras BatchNormalization 层

python - Keras 中的 3D 卷积是否适用于 RGB 视频?

python - 使用 for 循环追加 3D 数组

python - 使用 nohup 时更改 python 版本

python - 排序和比较 Dicts Python 列表

tensorflow - GPU -> CPU Memcpy 在 tensorflow word2vec 中失败 gpu 发生

python - 一起遍历列表的列表和列表

python - 我试图在 if 语句 python3 中的一个单词下划线

python-3.x - 如何检查 boto3 S3.Client.upload_fileobj 是否成功?