當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。