hp.choice('learning_rate_func', [ { 'scheduler': tf.compat.v1.train.piecewise_constant, 'scheduler_factor': hp.uniform('scheduler_factor', 0.05, 0.5), 'scheduler_steps': [25000, 50000, 75000], }, ]), 'weight_decay_rate': 0.0001, } NETWORK = SmartDict() NETWORK.OPTIMIZER_CLASS = None NETWORK.OPTIMIZER_KWARGS = {} NETWORK.LEARNING_RATE_FUNC = None NETWORK.LEARNING_RATE_KWARGS = {} NETWORK.WEIGHT_DECAY_RATE = None NETWORK.IMAGE_SIZE = IMAGE_SIZE NETWORK.BATCH_SIZE = BATCH_SIZE NETWORK.DATA_FORMAT = DATA_FORMAT NETWORK.ACTIVATION_QUANTIZER = linear_mid_tread_half_quantizer NETWORK.ACTIVATION_QUANTIZER_KWARGS = {'bit': 2, 'max_value': 2} NETWORK.WEIGHT_QUANTIZER = binary_mean_scaling_quantizer NETWORK.WEIGHT_QUANTIZER_KWARGS = {} # dataset DATASET = SmartDict() DATASET.BATCH_SIZE = BATCH_SIZE DATASET.DATA_FORMAT = DATA_FORMAT DATASET.PRE_PROCESSOR = PRE_PROCESSOR DATASET.AUGMENTOR = Sequence([
ExcludeLowScoreBox(threshold=score_threshold), NMS( iou_threshold=nms_iou_threshold, max_output_size=nms_max_output_size, classes=CLASSES, ), ]) NETWORK = SmartDict() NETWORK.OPTIMIZER_CLASS = tf.compat.v1.train.MomentumOptimizer NETWORK.OPTIMIZER_KWARGS = {"momentum": 0.9} NETWORK.LEARNING_RATE_FUNC = tf.compat.v1.train.piecewise_constant _epoch_steps = 16551 // BATCH_SIZE NETWORK.LEARNING_RATE_KWARGS = { "values": [1e-6, 1e-4, 1e-5, 1e-6, 1e-7], "boundaries": [_epoch_steps, _epoch_steps * 10, _epoch_steps * 60, _epoch_steps * 90], } NETWORK.IMAGE_SIZE = IMAGE_SIZE NETWORK.BATCH_SIZE = BATCH_SIZE NETWORK.DATA_FORMAT = DATA_FORMAT NETWORK.ANCHORS = anchors NETWORK.OBJECT_SCALE = 5.0 NETWORK.NO_OBJECT_SCALE = 1.0 NETWORK.CLASS_SCALE = 1.0 NETWORK.COORDINATE_SCALE = 1.0 NETWORK.LOSS_IOU_THRESHOLD = 0.6 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
# pretrain IS_PRETRAIN = False PRETRAIN_VARS = [] PRETRAIN_DIR = "" PRETRAIN_FILE = "" PRE_PROCESSOR = Sequence([Resize(size=IMAGE_SIZE), DivideBy255()]) POST_PROCESSOR = None NETWORK = SmartDict() NETWORK.OPTIMIZER_CLASS = tf.compat.v1.train.MomentumOptimizer NETWORK.OPTIMIZER_KWARGS = {"momentum": 0.9} NETWORK.LEARNING_RATE_FUNC = tf.compat.v1.train.cosine_decay # Train data num is 28709 step_per_epoch = 28709 // BATCH_SIZE NETWORK.LEARNING_RATE_KWARGS = {'learning_rate': 0.1, 'decay_steps': 100000} NETWORK.IMAGE_SIZE = IMAGE_SIZE NETWORK.BATCH_SIZE = BATCH_SIZE NETWORK.DATA_FORMAT = DATA_FORMAT NETWORK.WEIGHT_DECAY_RATE = 0.0005 NETWORK.ACTIVATION_QUANTIZER = linear_mid_tread_half_quantizer NETWORK.ACTIVATION_QUANTIZER_KWARGS = {'bit': 2, 'max_value': 2} NETWORK.WEIGHT_QUANTIZER = binary_mean_scaling_quantizer NETWORK.WEIGHT_QUANTIZER_KWARGS = {} # dataset DATASET = SmartDict() DATASET.BATCH_SIZE = BATCH_SIZE DATASET.DATA_FORMAT = DATA_FORMAT DATASET.PRE_PROCESSOR = PRE_PROCESSOR DATASET.AUGMENTOR = Sequence([
classes=CLASSES, ), ]) NETWORK = SmartDict() NETWORK.OPTIMIZER_CLASS = tf.compat.v1.train.MomentumOptimizer NETWORK.OPTIMIZER_KWARGS = {"momentum": 0.9} NETWORK.LEARNING_RATE_FUNC = tf.compat.v1.train.piecewise_constant # In the origianl yolov2 Paper, with a starting learning rate of 10−3, dividing it by 10 at 60 and 90 epochs. # Train data num per epoch is 16551 step_per_epoch = 16551 // BATCH_SIZE NETWORK.LEARNING_RATE_KWARGS = { "values": [5e-4, 2e-2, 5e-3, 5e-4, 5e-5], "boundaries": [ step_per_epoch * 5, step_per_epoch * 80, step_per_epoch * 120, step_per_epoch * 140 ], } NETWORK.IMAGE_SIZE = IMAGE_SIZE NETWORK.BATCH_SIZE = BATCH_SIZE NETWORK.DATA_FORMAT = DATA_FORMAT NETWORK.ANCHORS = anchors NETWORK.OBJECT_SCALE = 5.0 NETWORK.NO_OBJECT_SCALE = 1.0 NETWORK.CLASS_SCALE = 1.0 NETWORK.COORDINATE_SCALE = 1.0 NETWORK.LOSS_IOU_THRESHOLD = 0.6 NETWORK.WEIGHT_DECAY_RATE = 0.0005 NETWORK.SCORE_THRESHOLD = score_threshold
# SUMMARISE_STEPS = 2 # IS_DEBUG = True PRE_PROCESSOR = Sequence([ Resize(size=IMAGE_SIZE), DivideBy255(), ]) POST_PROCESSOR = None NETWORK = SmartDict() 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 * 100, step_per_epoch * 150, step_per_epoch * 175], } NETWORK.IMAGE_SIZE = IMAGE_SIZE NETWORK.BATCH_SIZE = BATCH_SIZE NETWORK.DATA_FORMAT = DATA_FORMAT NETWORK.WEIGHT_DECAY_RATE = 0.00004 # dataset DATASET = SmartDict() 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(),
# TEST_STEPS = 10 # SUMMARISE_STEPS = 2 # IS_DEBUG = True PRE_PROCESSOR = Sequence([ Resize(size=IMAGE_SIZE), PerImageStandardization() ]) POST_PROCESSOR = None NETWORK = SmartDict() NETWORK.OPTIMIZER_CLASS = tf.compat.v1.train.MomentumOptimizer NETWORK.OPTIMIZER_KWARGS = {"momentum": 0.9} NETWORK.LEARNING_RATE_FUNC = tf.compat.v1.train.piecewise_constant NETWORK.LEARNING_RATE_KWARGS = { "values": [0.1, 0.01, 0.001, 0.0001], "boundaries": [40000, 60000, 80000], } NETWORK.IMAGE_SIZE = IMAGE_SIZE NETWORK.BATCH_SIZE = BATCH_SIZE NETWORK.DATA_FORMAT = DATA_FORMAT # dataset DATASET = SmartDict() 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(), ])
max_output_size=nms_max_output_size, classes=CLASSES,), ]) NETWORK = SmartDict() NETWORK.OPTIMIZER_CLASS = tf.compat.v1.train.MomentumOptimizer NETWORK.OPTIMIZER_KWARGS = {"momentum": 0.9} NETWORK.LEARNING_RATE_FUNC = tf.compat.v1.train.piecewise_constant # In the origianl yolov2 Paper, with a starting learning rate of 10−3, dividing it by 10 at 60 and 90 epochs. # Train data num per epoch is 69863 step_per_epoch = 69863 // BATCH_SIZE NETWORK.LEARNING_RATE_KWARGS = { "values": [1e-4, 2e-3, 5e-4, 5e-5, 5e-6], "boundaries": [ step_per_epoch, step_per_epoch * 60, step_per_epoch * 90, step_per_epoch * 120, ], } NETWORK.IMAGE_SIZE = IMAGE_SIZE NETWORK.BATCH_SIZE = BATCH_SIZE NETWORK.DATA_FORMAT = DATA_FORMAT NETWORK.ANCHORS = anchors NETWORK.OBJECT_SCALE = 5.0 NETWORK.NO_OBJECT_SCALE = 1.0 NETWORK.CLASS_SCALE = 1.0 NETWORK.COORDINATE_SCALE = 1.0 NETWORK.LOSS_IOU_THRESHOLD = 0.6 NETWORK.WEIGHT_DECAY_RATE = 0.0005 NETWORK.SCORE_THRESHOLD = score_threshold
# SUMMARISE_STEPS = 2 # IS_DEBUG = True PRE_PROCESSOR = Sequence([ Resize(size=IMAGE_SIZE), DivideBy255() ]) POST_PROCESSOR = None NETWORK = SmartDict() 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 // 200 NETWORK.LEARNING_RATE_KWARGS = { "values": [0.01, 0.001, 0.0001, 0.00001], "boundaries": [step_per_epoch * 200, step_per_epoch * 300, step_per_epoch * 350], } NETWORK.IMAGE_SIZE = IMAGE_SIZE NETWORK.BATCH_SIZE = BATCH_SIZE NETWORK.DATA_FORMAT = DATA_FORMAT NETWORK.WEIGHT_DECAY_RATE = 0.0005 # dataset DATASET = SmartDict() 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(),
# SAVE_CHECKPOINT_STEPS = 2 # TEST_STEPS = 10 # SUMMARISE_STEPS = 2 # IS_DEBUG = True PRE_PROCESSOR = Sequence([Resize(size=IMAGE_SIZE), DivideBy255()]) POST_PROCESSOR = None NETWORK = SmartDict() NETWORK.OPTIMIZER_CLASS = tf.compat.v1.train.MomentumOptimizer NETWORK.OPTIMIZER_KWARGS = {"momentum": 0.9} NETWORK.LEARNING_RATE_FUNC = tf.compat.v1.train.polynomial_decay # TODO(wakiska): It is same as original yolov2 paper (batch size = 128). NETWORK.LEARNING_RATE_KWARGS = { "learning_rate": 1e-1, "decay_steps": 1600000, "power": 4.0, "end_learning_rate": 0.0 } NETWORK.IMAGE_SIZE = IMAGE_SIZE NETWORK.BATCH_SIZE = BATCH_SIZE NETWORK.DATA_FORMAT = DATA_FORMAT NETWORK.WEIGHT_DECAY_RATE = 0.0005 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 = True NETWORK.QUANTIZE_LAST_CONVOLUTION = False
# for debug # BATCH_SIZE = 2 # SUMMARISE_STEPS = 1 # IS_DEBUG = True PRE_PROCESSOR = Sequence([ Resize(size=IMAGE_SIZE), {% if quantize_first_convolution %}DivideBy255(){% else %}PerImageStandardization(){% endif %} ]) POST_PROCESSOR = None NETWORK = SmartDict() NETWORK.OPTIMIZER_CLASS = {{optimizer_class}} NETWORK.OPTIMIZER_KWARGS = {{optimizer_kwargs}} NETWORK.LEARNING_RATE_FUNC = {{learning_rate_func}} NETWORK.LEARNING_RATE_KWARGS = {{learning_rate_kwargs}} NETWORK.IMAGE_SIZE = IMAGE_SIZE NETWORK.BATCH_SIZE = BATCH_SIZE NETWORK.DATA_FORMAT = DATA_FORMAT NETWORK.ACTIVATION_QUANTIZER = linear_mid_tread_half_quantizer NETWORK.ACTIVATION_QUANTIZER_KWARGS = { 'bit': 2, 'max_value': 2 } NETWORK.WEIGHT_QUANTIZER = binary_mean_scaling_quantizer NETWORK.WEIGHT_QUANTIZER_KWARGS = {} DATASET = SmartDict() DATASET.BATCH_SIZE = BATCH_SIZE DATASET.DATA_FORMAT = DATA_FORMAT
JointsToGaussianHeatmap(image_size=IMAGE_SIZE, stride=STRIDE, sigma=2), DivideBy255() ]) POST_PROCESSOR = Sequence([ GaussianHeatmapToJoints(num_dimensions=2, stride=STRIDE, confidence_threshold=0.1) ]) step_per_epoch = 149813 // BATCH_SIZE NETWORK = SmartDict() NETWORK.OPTIMIZER_CLASS = tf.compat.v1.train.AdamOptimizer NETWORK.OPTIMIZER_KWARGS = {} NETWORK.LEARNING_RATE_FUNC = tf.compat.v1.train.piecewise_constant NETWORK.LEARNING_RATE_KWARGS = { "values": [1e-4, 1e-3, 1e-4, 1e-5], "boundaries": [5000, step_per_epoch * 5, step_per_epoch * 10], } NETWORK.STRIDE = STRIDE NETWORK.IMAGE_SIZE = IMAGE_SIZE NETWORK.BATCH_SIZE = BATCH_SIZE NETWORK.DATA_FORMAT = DATA_FORMAT NETWORK.ACTIVATION_QUANTIZER = linear_mid_tread_half_quantizer NETWORK.ACTIVATION_QUANTIZER_KWARGS = { 'bit': 2, 'max_value': 2 } NETWORK.WEIGHT_QUANTIZER = binary_channel_wise_mean_scaling_quantizer NETWORK.WEIGHT_QUANTIZER_KWARGS = {} DATASET = SmartDict() DATASET.IMAGE_SIZE = IMAGE_SIZE