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

Method get_updates

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

Source from the content-addressed store, hash-verified

180 self.nesterov = nesterov
181
182 def get_updates(self, loss, params):
183 grads = self.get_gradients(loss, params)
184 self.updates = [state_ops.assign_add(self.iterations, 1)]
185
186 lr = self.lr
187 if self.initial_decay > 0:
188 lr = lr * ( # pylint: disable=g-no-augmented-assignment
189 1. /
190 (1. +
191 self.decay * math_ops.cast(self.iterations, K.dtype(self.decay))))
192 # momentum
193 shapes = [K.int_shape(p) for p in params]
194 moments = [K.zeros(shape) for shape in shapes]
195 self.weights = [self.iterations] + moments
196 for p, g, m in zip(params, grads, moments):
197 v = self.momentum * m - lr * g # velocity
198 self.updates.append(state_ops.assign(m, v))
199
200 if self.nesterov:
201 new_p = p + self.momentum * v - lr * g
202 else:
203 new_p = p + v
204
205 # Apply constraints.
206 if getattr(p, 'constraint', None) is not None:
207 new_p = p.constraint(new_p)
208
209 self.updates.append(state_ops.assign(p, new_p))
210 return self.updates
211
212 def get_config(self):
213 config = {

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected