当前位置: 首页>>代码示例>>Python>>正文


Python datasets.IMAGENET_NUM_TRAIN_IMAGES属性代码示例

本文整理汇总了Python中datasets.IMAGENET_NUM_TRAIN_IMAGES属性的典型用法代码示例。如果您正苦于以下问题:Python datasets.IMAGENET_NUM_TRAIN_IMAGES属性的具体用法?Python datasets.IMAGENET_NUM_TRAIN_IMAGES怎么用?Python datasets.IMAGENET_NUM_TRAIN_IMAGES使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在datasets的用法示例。


在下文中一共展示了datasets.IMAGENET_NUM_TRAIN_IMAGES属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_learning_rate

# 需要导入模块: import datasets [as 别名]
# 或者: from datasets import IMAGENET_NUM_TRAIN_IMAGES [as 别名]
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) 
开发者ID:snuspl,项目名称:parallax,代码行数:25,代码来源:resnet_model.py

示例2: get_learning_rate

# 需要导入模块: import datasets [as 别名]
# 或者: from datasets import IMAGENET_NUM_TRAIN_IMAGES [as 别名]
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) 
开发者ID:tensorflow,项目名称:benchmarks,代码行数:11,代码来源:official_resnet_model.py

示例3: get_learning_rate

# 需要导入模块: import datasets [as 别名]
# 或者: from datasets import IMAGENET_NUM_TRAIN_IMAGES [as 别名]
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) 
开发者ID:tensorflow,项目名称:benchmarks,代码行数:16,代码来源:resnet_model.py

示例4: testEvalDuringTrainingNumEpochs

# 需要导入模块: import datasets [as 别名]
# 或者: from datasets import IMAGENET_NUM_TRAIN_IMAGES [as 别名]
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) 
开发者ID:tensorflow,项目名称:benchmarks,代码行数:13,代码来源:benchmark_cnn_test.py

示例5: get_learning_rate

# 需要导入模块: import datasets [as 别名]
# 或者: from datasets import IMAGENET_NUM_TRAIN_IMAGES [as 别名]
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) 
开发者ID:awslabs,项目名称:deeplearning-benchmark,代码行数:8,代码来源:resnet_model.py


注:本文中的datasets.IMAGENET_NUM_TRAIN_IMAGES属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。