本文整理汇总了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)
示例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)
示例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)
示例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)
示例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)