MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / get_updates

Method get_updates

tensorflow/python/keras/optimizers.py:249–273  ·  view source on GitHub ↗
(self, loss, params)

Source from the content-addressed store, hash-verified

247 self.initial_decay = decay
248
249 def get_updates(self, loss, params):
250 grads = self.get_gradients(loss, params)
251 accumulators = [K.zeros(K.int_shape(p), dtype=K.dtype(p)) for p in params]
252 self.weights = accumulators
253 self.updates = [state_ops.assign_add(self.iterations, 1)]
254
255 lr = self.lr
256 if self.initial_decay > 0:
257 lr = lr * ( # pylint: disable=g-no-augmented-assignment
258 1. /
259 (1. +
260 self.decay * math_ops.cast(self.iterations, K.dtype(self.decay))))
261
262 for p, g, a in zip(params, grads, accumulators):
263 # update accumulator
264 new_a = self.rho * a + (1. - self.rho) * math_ops.square(g)
265 self.updates.append(state_ops.assign(a, new_a))
266 new_p = p - lr * g / (K.sqrt(new_a) + self.epsilon)
267
268 # Apply constraints.
269 if getattr(p, 'constraint', None) is not None:
270 new_p = p.constraint(new_p)
271
272 self.updates.append(state_ops.assign(p, new_p))
273 return self.updates
274
275 def get_config(self):
276 config = {

Callers

nothing calls this directly

Calls 8

get_gradientsMethod · 0.45
dtypeMethod · 0.45
assign_addMethod · 0.45
castMethod · 0.45
squareMethod · 0.45
appendMethod · 0.45
assignMethod · 0.45
constraintMethod · 0.45

Tested by

no test coverage detected