zoukankan      html  css  js  c++  java
  • tensorflow API _ 3 (tf.train.polynomial_decay)

    学习率的三种调整方式:
    固定的,指数的,多项式的

    def _configure_learning_rate(num_samples_per_epoch, global_step):
    """Configures the learning rate.

    Args:
    num_samples_per_epoch: The number of samples in each epoch of training.
    global_step: The global_step tensor.

    Returns:
    A `Tensor` representing the learning rate.

    Raises:
    ValueError: if
    """
    decay_steps = int(num_samples_per_epoch / FLAGS.batch_size *
    FLAGS.num_epochs_per_decay)
    if FLAGS.sync_replicas:
    decay_steps /= FLAGS.replicas_to_aggregate

    if FLAGS.learning_rate_decay_type == 'exponential':
    return tf.train.exponential_decay(FLAGS.learning_rate,
    global_step,
    decay_steps,
    FLAGS.learning_rate_decay_factor,
    staircase=True,
    name='exponential_decay_learning_rate')
    elif FLAGS.learning_rate_decay_type == 'fixed':
    return tf.constant(FLAGS.learning_rate, name='fixed_learning_rate')
    elif FLAGS.learning_rate_decay_type == 'polynomial':
    return tf.train.polynomial_decay(FLAGS.learning_rate,
    global_step,
    decay_steps,
    FLAGS.end_learning_rate,
    power=1.0,
    cycle=False,
    name='polynomial_decay_learning_rate')
    else:
    raise ValueError('learning_rate_decay_type [%s] was not recognized',
    FLAGS.learning_rate_decay_type)
  • 相关阅读:
    HDU4857 逃生 拓扑排序
    HDU1285 确定名次 拓扑排序
    【noip模拟赛4】找啊找啊找BF 拓扑排序
    拓扑排序基础
    【noip模拟赛5】任务分配 降维dp
    【noip模拟赛6】收入计划 最大值的最小值 二分答案
    【noip模拟赛5】水流
    标记预期失败
    跳过:
    pytest配置文件:
  • 原文地址:https://www.cnblogs.com/Libo-Master/p/8926136.html
Copyright © 2011-2022 走看看