484ffb3eae65a09c717a6c823dcc888d5750df6c,sonnet/src/momentum.py,Momentum,apply,#Momentum#Any#Any#,67
Before Change
self._initialize(parameters)
for update, parameter, momentum in zip(updates, parameters,
self.accumulated_momentum):
if update is not None:
optimizer_utils.check_same_dtype(update, parameter)
lr = tf.cast(self.learning_rate, update.dtype)
mu = tf.cast(self.momentum, update.dtype)
if isinstance(update, tf.IndexedSlices):
update, indices = optimizer_utils.deduplicate_indexed_slices(
update.values, update.indices)
sparse_momentum_update = (mu * momentum.sparse_read(indices)) + update
momentum.scatter_update(
tf.IndexedSlices(sparse_momentum_update, indices))
if self.use_nesterov:
parameter.scatter_sub(
tf.IndexedSlices(
(lr * update) + (lr * mu * sparse_momentum_update),
indices))
else:
parameter.scatter_sub(
tf.IndexedSlices(lr * sparse_momentum_update, indices))
else:
momentum.assign((mu * momentum) + update)
if self.use_nesterov:
parameter.assign_sub((lr * update) + (lr * mu * momentum))
else:
parameter.assign_sub(lr * momentum)
class FastMomentum(base.Optimizer):
SGD with Momentum module.
def __init__(self,
After Change
momentum = momentum_var.sparse_read(indices)
// Compute and apply a sparse update to our parameter and state.
update, momentum = momentum_update(update, learning_rate, mu, momentum,
self.use_nesterov)
momentum_var.scatter_update(tf.IndexedSlices(momentum, indices))
param.scatter_sub(tf.IndexedSlices(update, indices))
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 4
Instances
Project Name: deepmind/sonnet
Commit Name: 484ffb3eae65a09c717a6c823dcc888d5750df6c
Time: 2019-10-16
Author: tomhennigan@google.com
File Name: sonnet/src/momentum.py
Class Name: Momentum
Method Name: apply
Project Name: QUANTAXIS/QUANTAXIS
Commit Name: fa93a0d733bd88e236e2b5090c433088b729d113
Time: 2020-08-04
Author: yutiansut@qq.com
File Name: QUANTAXIS/QAFetch/QATdx.py
Class Name:
Method Name: QA_fetch_get_stock_list
Project Name: QUANTAXIS/QUANTAXIS
Commit Name: 4113a6a3be19167a8c551f8ae20e849ac851e52c
Time: 2019-03-25
Author: zhongjy1992@outlook.com
File Name: QUANTAXIS/QAFetch/QAQuery.py
Class Name:
Method Name: QA_fetch_index_day