本文整理匯總了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