MCPcopy
hub / github.com/junyanz/iGAN / __call__

Method __call__

lib/updates.py:168–190  ·  view source on GitHub ↗
(self, params, cost)

Source from the content-addressed store, hash-verified

166 self.__dict__.update(locals())
167
168 def __call__(self, params, cost):
169 updates = []
170 grads = T.grad(cost, params)
171 grads = clip_norms(grads, self.clipnorm)
172 t = theano.shared(floatX(1.))
173 b1_t = self.b1 * self.l**(t - 1)
174
175 for p, g in zip(params, grads):
176 g = self.regularizer.gradient_regularize(p, g)
177 m = theano.shared(p.get_value() * 0.)
178 v = theano.shared(p.get_value() * 0.)
179
180 m_t = b1_t * m + (1 - b1_t) * g
181 v_t = self.b2 * v + (1 - self.b2) * g**2
182 m_c = m_t / (1 - self.b1**t)
183 v_c = v_t / (1 - self.b2**t)
184 p_t = p - (self.lr * m_c) / (T.sqrt(v_c) + self.e)
185 p_t = self.regularizer.weight_regularize(p_t)
186 updates.append((m, m_t))
187 updates.append((v, v_t))
188 updates.append((p, p_t))
189 updates.append((t, t + 1.))
190 return updates
191
192
193class Adagrad(Update):

Callers

nothing calls this directly

Calls 4

clip_normsFunction · 0.85
floatXFunction · 0.85
gradient_regularizeMethod · 0.80
weight_regularizeMethod · 0.80

Tested by

no test coverage detected