(self, params, cost)
| 144 | self.__dict__.update(locals()) |
| 145 | |
| 146 | def __call__(self, params, cost): |
| 147 | updates = [] |
| 148 | grads = T.grad(cost, params) |
| 149 | grads = clip_norms(grads, self.clipnorm) |
| 150 | for p, g in zip(params, grads): |
| 151 | g = self.regularizer.gradient_regularize(p, g) |
| 152 | acc = theano.shared(p.get_value() * 0.) |
| 153 | acc_new = self.rho * acc + (1 - self.rho) * g ** 2 |
| 154 | updates.append((acc, acc_new)) |
| 155 | |
| 156 | updated_p = p - self.lr * (g / T.sqrt(acc_new + self.epsilon)) |
| 157 | updated_p = self.regularizer.weight_regularize(updated_p) |
| 158 | updates.append((p, updated_p)) |
| 159 | return updates |
| 160 | |
| 161 | |
| 162 | class Adam(Update): |
nothing calls this directly
no test coverage detected