本文整理汇总了Python中tensorflow.python.training.moving_averages.ExponentialMovingAverage方法的典型用法代码示例。如果您正苦于以下问题:Python moving_averages.ExponentialMovingAverage方法的具体用法?Python moving_averages.ExponentialMovingAverage怎么用?Python moving_averages.ExponentialMovingAverage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tensorflow.python.training.moving_averages
的用法示例。
在下文中一共展示了moving_averages.ExponentialMovingAverage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from tensorflow.python.training import moving_averages [as 别名]
# 或者: from tensorflow.python.training.moving_averages import ExponentialMovingAverage [as 别名]
def __init__(self, opt, average_decay=0.9999, num_updates=None,
sequential_update=True):
"""Construct a new MovingAverageOptimizer.
Args:
opt: A tf.Optimizer that will be used to compute and apply gradients.
average_decay: Float. Decay to use to maintain the moving averages
of trained variables.
See tf.train.ExponentialMovingAverage for details.
num_updates: Optional count of number of updates applied to variables.
See tf.train.ExponentialMovingAverage for details.
sequential_update: Bool. If False, will compute the moving average at the
same time as the model is updated, potentially doing
benign data races.
If True, will update the moving average after gradient
updates.
"""
self._optimizer = opt
self._ema = moving_averages.ExponentialMovingAverage(
average_decay, num_updates=num_updates)
self._variable_map = None
self._sequential_update = sequential_update
示例2: __init__
# 需要导入模块: from tensorflow.python.training import moving_averages [as 别名]
# 或者: from tensorflow.python.training.moving_averages import ExponentialMovingAverage [as 别名]
def __init__(self, optimizer, begin_step, end_step, frequency,
drop_fraction=0.1, drop_fraction_anneal='constant',
use_locking=False, grow_init='zeros', momentum=0.9,
use_tpu=False, name='SparseMomentumOptimizer',
stateless_seed_offset=0):
super(SparseMomentumOptimizer, self).__init__(
optimizer, begin_step, end_step, frequency, drop_fraction=drop_fraction,
drop_fraction_anneal=drop_fraction_anneal, grow_init=grow_init,
use_locking=use_locking, name='SparseMomentumOptimizer',
stateless_seed_offset=stateless_seed_offset)
self._ema_grads = moving_averages.ExponentialMovingAverage(decay=momentum)
self._use_tpu = use_tpu