(self, loss, params)
| 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 = { |
nothing calls this directly
no test coverage detected