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

Method get_updates

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

Source from the content-addressed store, hash-verified

316 self.initial_decay = decay
317
318 def get_updates(self, loss, params):
319 grads = self.get_gradients(loss, params)
320 shapes = [K.int_shape(p) for p in params]
321 accumulators = [K.zeros(shape) for shape in shapes]
322 self.weights = accumulators
323 self.updates = [state_ops.assign_add(self.iterations, 1)]
324
325 lr = self.lr
326 if self.initial_decay > 0:
327 lr = lr * ( # pylint: disable=g-no-augmented-assignment
328 1. /
329 (1. +
330 self.decay * math_ops.cast(self.iterations, K.dtype(self.decay))))
331
332 for p, g, a in zip(params, grads, accumulators):
333 new_a = a + math_ops.square(g) # update accumulator
334 self.updates.append(state_ops.assign(a, new_a))
335 new_p = p - lr * g / (K.sqrt(new_a) + self.epsilon)
336
337 # Apply constraints.
338 if getattr(p, 'constraint', None) is not None:
339 new_p = p.constraint(new_p)
340
341 self.updates.append(state_ops.assign(p, new_p))
342 return self.updates
343
344 def get_config(self):
345 config = {

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected