NETWORK.WEIGHT_DECAY_RATE = 0.0005 NETWORK.SCORE_THRESHOLD = score_threshold NETWORK.NMS_IOU_THRESHOLD = nms_iou_threshold NETWORK.NMS_MAX_OUTPUT_SIZE = nms_max_output_size NETWORK.LOSS_WARMUP_STEPS = int(8000 / BATCH_SIZE) # quantize NETWORK.ACTIVATION_QUANTIZER = linear_mid_tread_half_quantizer NETWORK.ACTIVATION_QUANTIZER_KWARGS = { 'bit': 2, 'max_value': 2.0 } NETWORK.WEIGHT_QUANTIZER = binary_channel_wise_mean_scaling_quantizer NETWORK.WEIGHT_QUANTIZER_KWARGS = {} NETWORK.QUANTIZE_FIRST_CONVOLUTION = False NETWORK.QUANTIZE_LAST_CONVOLUTION = False # dataset DATASET = EasyDict() DATASET.BATCH_SIZE = BATCH_SIZE DATASET.DATA_FORMAT = DATA_FORMAT DATASET.PRE_PROCESSOR = PRE_PROCESSOR DATASET.AUGMENTOR = Sequence([ Brightness(value=(0.75, 1.25), ), Color(value=(0.75, 1.25), ), FlipLeftRight(probability=0.5, ), Hue(value=(-10, 10), ), SSDRandomCrop(min_crop_ratio=0.3, ), ]) DATASET.ENABLE_PREFETCH = True
PRE_PROCESSOR = Sequence([ Resize(size=IMAGE_SIZE), PerImageStandardization(), ]) POST_PROCESSOR = None NETWORK = EasyDict() NETWORK.OPTIMIZER_CLASS = tf.compat.v1.train.MomentumOptimizer NETWORK.OPTIMIZER_KWARGS = {"momentum": 0.9} NETWORK.LEARNING_RATE_FUNC = tf.compat.v1.train.piecewise_constant step_per_epoch = 50000 // BATCH_SIZE NETWORK.LEARNING_RATE_KWARGS = { "values": [0.01, 0.1, 0.01, 0.001, 0.0001], "boundaries": [step_per_epoch, step_per_epoch * 50, step_per_epoch * 100, step_per_epoch * 198], } NETWORK.IMAGE_SIZE = IMAGE_SIZE NETWORK.BATCH_SIZE = BATCH_SIZE NETWORK.DATA_FORMAT = DATA_FORMAT NETWORK.WEIGHT_DECAY_RATE = 0.0005 # dataset DATASET = EasyDict() DATASET.BATCH_SIZE = BATCH_SIZE DATASET.DATA_FORMAT = DATA_FORMAT DATASET.PRE_PROCESSOR = PRE_PROCESSOR DATASET.AUGMENTOR = Sequence([ Pad(2), Crop(size=IMAGE_SIZE), FlipLeftRight(), ])
if self.enable_prefetch: self.prefetcher.terminate = True self.prefetcher.pool.close() self.prefetcher.pool.join() if __name__ == '__main__': from blueoil.datasets.cifar10 import Cifar10 from blueoil.data_processor import Sequence from blueoil.data_augmentor import FlipLeftRight, Hue, Blur cifar10 = Cifar10() augmentor = Sequence([ FlipLeftRight(0.5), Hue((-10, 10)), Blur(), ]) dataset_iterator = DatasetIterator(dataset=cifar10, enable_prefetch=True, augmentor=augmentor) time.sleep(2) import time t0 = time.time() data_batch = next(dataset_iterator) t1 = time.time() print("time of prefetch: {}".format(t1 - t0)) dataset_iterator2 = DatasetIterator(dataset=cifar10,