我正在使用 Faster-RCNN 模型和 Tensorflow 对象检测 API 来开发徽标检测算法。
我的数据集按字母顺序排列(因此有一百个阿迪达斯徽标,然后是一百个苹果徽标等)。我希望在训练时对其进行洗牌。
我在配置文件中添加了一些值:
train_input_reader:{
shuffle: true
queue_capacity: some value
min_after_dequeue : some other value}
然而,无论我输入什么值,算法首先对所有 a 的徽标(阿迪达斯、苹果等)进行训练,并且在开始看到 b 的徽标(宝马等)后仅经过一段时间,然后c 是一个等等。
当然,我可以直接打乱输入数据集,但我想了解其背后的逻辑。
PS:我见过这个post https://stackoverflow.com/questions/43028683/whats-going-on-in-tf-train-shuffle-batch-and-tf-train-batch关于洗牌和min_after_dequeue,但我仍然不太明白。我的批量大小是 1 所以不应该使用tf.train.shuffle_batch()
但只有tf.RandomShuffleQueue
我的训练数据集大小是 5000,如果我写min_after_dequeue: 4000 or 5000
它仍然没有被正确洗牌。为什么呢?
更新:
@AllenLavoie 这对我来说有点难;因为有很多依赖项,而且我是 Tensorflow 的新手。
但最终队列是由
tf.contrib.slim.parallel_reader.parallel_read( _, string_tensor = parallel_reader.parallel_read(
config.input_path,
reader_class=tf.TFRecordReader,
num_epochs=(input_reader_config.num_epochs
if input_reader_config.num_epochs else None),
num_readers=input_reader_config.num_readers,
shuffle=input_reader_config.shuffle,
dtypes=[tf.string, tf.string],
capacity=input_reader_config.queue_capacity,
min_after_dequeue=input_reader_config.min_after_dequeue)
看来当我把num_readers = 1
在配置文件中,数据集最终按照我想要的方式进行洗牌(至少在开始时),但是当开始时有更多的徽标时,徽标将按字母顺序排列。