Open linshufei opened 4 years ago
版本、环境信息: 1)PaddlePaddle版本:1.6 2)CPU:CPU 3)GPU:无 4)系统环境:Linux python2.7 metric learning中的reader.py源码如下:createreader中的keep_order ` def createreader(settings, mode): def metric_reader(): if mode == 'train': train_data, train_image_list = init_sop('train') loss_name = settings.loss_name if loss_name in ["softmax", "arcmargin"]: return arcmargin_iterator(train_image_list, settings)() elif loss_name == 'triplet': return triplet_iterator(train_data, settings)() else: return common_iterator(train_data, settings)() elif mode == 'val': val_data, val_image_list = init_sop('val') return image_iterator(val_image_list, 'val')() else: test_image_list = init_sop('test') return image_iterator(test_image_list, 'test')()
image_shape = settings.image_shape.split(',') assert(image_shape[1] == image_shape[2]) image_size = int(image_shape[2]) keep_order = False if mode != 'train' or settings.loss_name in ['softmax', 'arcmargin'] else True image_mapper = functools.partial(process_image, mode=mode, color_jitter=False, rotate=False, crop_size=image_size) reader = paddle.reader.xmap_readers( image_mapper, metric_reader, 8, 1000, order=keep_order) return reader
` 问题描述: keep_order = False if mode != 'train' or settings.loss_name in ['softmax', 'arcmargin'] else True中当非训练模式置keep_order为False的作用是什么?
reader里面keep_order的作用是: 设置为True, 在训triplet,quadruplet 等pair对的loss,保持一个batch里面pair对的顺序不变; 设置为False,经过reader的多线程处理后,一个batch里面的数据顺序会乱掉, 这对softmax,arcmargin以及test模型都不影响,它们都不依赖batch里数据的顺序。
如果都设置为True,对训练有什么影响?
版本、环境信息: 1)PaddlePaddle版本:1.6 2)CPU:CPU 3)GPU:无 4)系统环境:Linux python2.7 metric learning中的reader.py源码如下:createreader中的keep_order ` def createreader(settings, mode): def metric_reader(): if mode == 'train': train_data, train_image_list = init_sop('train') loss_name = settings.loss_name if loss_name in ["softmax", "arcmargin"]: return arcmargin_iterator(train_image_list, settings)() elif loss_name == 'triplet': return triplet_iterator(train_data, settings)() else: return common_iterator(train_data, settings)() elif mode == 'val': val_data, val_image_list = init_sop('val') return image_iterator(val_image_list, 'val')() else: test_image_list = init_sop('test') return image_iterator(test_image_list, 'test')()
image_shape = settings.image_shape.split(',') assert(image_shape[1] == image_shape[2]) image_size = int(image_shape[2]) keep_order = False if mode != 'train' or settings.loss_name in ['softmax', 'arcmargin'] else True image_mapper = functools.partial(process_image, mode=mode, color_jitter=False, rotate=False, crop_size=image_size) reader = paddle.reader.xmap_readers( image_mapper, metric_reader, 8, 1000, order=keep_order) return reader
` 问题描述: keep_order = False if mode != 'train' or settings.loss_name in ['softmax', 'arcmargin'] else True中当非训练模式置keep_order为False的作用是什么?
reader里面keep_order的作用是: 设置为True, 在训triplet,quadruplet 等pair对的loss,保持一个batch里面pair对的顺序不变; 设置为False,经过reader的多线程处理后,一个batch里面的数据顺序会乱掉, 这对softmax,arcmargin以及test模型都不影响,它们都不依赖batch里数据的顺序。
如果都设置为True,对训练有什么影响?
如果都设置为True,对训练有什么影响?
reader速度会慢点,训练效果没影响。
版本、环境信息: 1)PaddlePaddle版本:1.6 2)CPU:CPU 3)GPU:无 4)系统环境:Linux python2.7 metric learning中的reader.py源码如下:createreader中的keep_order ` def createreader(settings, mode): def metric_reader(): if mode == 'train': train_data, train_image_list = init_sop('train') loss_name = settings.loss_name if loss_name in ["softmax", "arcmargin"]: return arcmargin_iterator(train_image_list, settings)() elif loss_name == 'triplet': return triplet_iterator(train_data, settings)() else: return common_iterator(train_data, settings)() elif mode == 'val': val_data, val_image_list = init_sop('val') return image_iterator(val_image_list, 'val')() else: test_image_list = init_sop('test') return image_iterator(test_image_list, 'test')()
` 问题描述: keep_order = False if mode != 'train' or settings.loss_name in ['softmax', 'arcmargin'] else True中当非训练模式置keep_order为False的作用是什么?