Python datasets.IMAGENET_NUM_TRAIN_IMAGES Examples

The following are 7 code examples of datasets.IMAGENET_NUM_TRAIN_IMAGES(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module datasets , or try the search function .
Example #1
Source File: resnet_model.py    From parallax with Apache License 2.0 6 votes vote down vote up
def get_learning_rate(self, global_step, batch_size):
        if FLAGS.deterministic:
            return tf.constant(0.1)
        num_batches_per_epoch = (
                float(datasets.IMAGENET_NUM_TRAIN_IMAGES) / batch_size)
        # five epochs for warmup
        warmup_batches = num_batches_per_epoch * 5

        # during warmup process, learning rate increases linearly from 0.1 to
        # initial learning rate
        learning_rate_before_warmup = 0.1
        learning_rate_after_warmup = batch_size / 256.0 * 0.1 if batch_size > 256 else 0.1
        inc_per_iter = (learning_rate_after_warmup
                        - learning_rate_before_warmup)\
                       / warmup_batches

        warmup = learning_rate_before_warmup + tf.multiply(
            tf.constant(inc_per_iter), tf.cast(global_step, dtype=tf.float32))
        boundaries = [int(num_batches_per_epoch * x) for x in [5, 30, 60, 80]]
        values = [warmup] + [learning_rate_after_warmup / 10 ** i for i in
                             range(4)]

        return tf.train.piecewise_constant(global_step, boundaries, values) 
Example #2
Source File: official_resnet_model.py    From benchmarks with Apache License 2.0 5 votes vote down vote up
def get_learning_rate(self, global_step, batch_size):
    num_batches_per_epoch = (
        float(datasets.IMAGENET_NUM_TRAIN_IMAGES) / batch_size)
    boundaries = [int(num_batches_per_epoch * x) for x in [30, 60, 80, 90]]
    values = [1, 0.1, 0.01, 0.001, 0.0001]
    adjusted_learning_rate = (
        self.learning_rate / self.default_batch_size * batch_size)
    values = [v * adjusted_learning_rate for v in values]
    return tf.train.piecewise_constant(global_step, boundaries, values) 
Example #3
Source File: resnet_model.py    From benchmarks with Apache License 2.0 5 votes vote down vote up
def get_learning_rate(self, global_step, batch_size):
    rescaled_lr = self.get_scaled_base_learning_rate(batch_size)
    num_batches_per_epoch = (
        datasets.IMAGENET_NUM_TRAIN_IMAGES / batch_size)
    boundaries = [int(num_batches_per_epoch * x) for x in [30, 60, 80, 90]]
    values = [1, 0.1, 0.01, 0.001, 0.0001]
    values = [rescaled_lr * v for v in values]
    lr = tf.train.piecewise_constant(global_step, boundaries, values)
    warmup_steps = int(num_batches_per_epoch * 5)
    mlperf.logger.log(key=mlperf.tags.OPT_LR_WARMUP_STEPS, value=warmup_steps)
    warmup_lr = (
        rescaled_lr * tf.cast(global_step, tf.float32) / tf.cast(
            warmup_steps, tf.float32))
    return tf.cond(global_step < warmup_steps, lambda: warmup_lr, lambda: lr) 
Example #4
Source File: benchmark_cnn_test.py    From benchmarks with Apache License 2.0 5 votes vote down vote up
def testEvalDuringTrainingNumEpochs(self):
    params = benchmark_cnn.make_params(
        batch_size=1, eval_batch_size=2, eval_during_training_every_n_steps=1,
        num_batches=30, num_eval_epochs=100 / datasets.IMAGENET_NUM_VAL_IMAGES)
    bench_cnn = benchmark_cnn.BenchmarkCNN(params)
    self.assertEqual(bench_cnn.num_batches, 30)
    self.assertAlmostEqual(bench_cnn.num_epochs,
                           30 / datasets.IMAGENET_NUM_TRAIN_IMAGES)
    self.assertAlmostEqual(bench_cnn.num_eval_batches, 50)
    self.assertAlmostEqual(bench_cnn.num_eval_epochs,
                           100 / datasets.IMAGENET_NUM_VAL_IMAGES) 
Example #5
Source File: resnet_model.py    From deeplearning-benchmark with Apache License 2.0 5 votes vote down vote up
def get_learning_rate(self, global_step, batch_size):
    num_batches_per_epoch = (
        float(datasets.IMAGENET_NUM_TRAIN_IMAGES) / batch_size)
    boundaries = [int(num_batches_per_epoch * x) for x in [30, 60]]
    values = [0.1, 0.01, 0.001]
    return tf.train.piecewise_constant(global_step, boundaries, values) 
Example #6
Source File: resnet_model.py    From tf-imagenet with Apache License 2.0 5 votes vote down vote up
def get_learning_rate(self, global_step, batch_size):
    num_batches_per_epoch = (
        float(datasets.IMAGENET_NUM_TRAIN_IMAGES) / batch_size)
    boundaries = [int(num_batches_per_epoch * x) for x in [30, 60]]
    values = [0.1, 0.01, 0.001]
    return tf.train.piecewise_constant(global_step, boundaries, values) 
Example #7
Source File: resnet_model.py    From dlcookbook-dlbs with Apache License 2.0 5 votes vote down vote up
def get_learning_rate(self, global_step, batch_size):
    num_batches_per_epoch = (
        float(datasets.IMAGENET_NUM_TRAIN_IMAGES) / batch_size)
    boundaries = [int(num_batches_per_epoch * x) for x in [30, 60]]
    values = [0.1, 0.01, 0.001]
    return tf.train.piecewise_constant(global_step, boundaries, values)