MCPcopy Index your code
hub / github.com/lisa-lab/DeepLearningTutorials / adadelta

Function adadelta

code/lstm.py:241–299  ·  view source on GitHub ↗

An adaptive learning rate optimizer Parameters ---------- lr : Theano SharedVariable Initial learning rate tpramas: Theano SharedVariable Model parameters grads: Theano variable Gradients of cost w.r.t to parameres x: Theano variable Mode

(lr, tparams, grads, x, mask, y, cost)

Source from the content-addressed store, hash-verified

239
240
241def adadelta(lr, tparams, grads, x, mask, y, cost):
242 """
243 An adaptive learning rate optimizer
244
245 Parameters
246 ----------
247 lr : Theano SharedVariable
248 Initial learning rate
249 tpramas: Theano SharedVariable
250 Model parameters
251 grads: Theano variable
252 Gradients of cost w.r.t to parameres
253 x: Theano variable
254 Model inputs
255 mask: Theano variable
256 Sequence mask
257 y: Theano variable
258 Targets
259 cost: Theano variable
260 Objective fucntion to minimize
261
262 Notes
263 -----
264 For more information, see [ADADELTA]_.
265
266 .. [ADADELTA] Matthew D. Zeiler, *ADADELTA: An Adaptive Learning
267 Rate Method*, arXiv:1212.5701.
268 """
269
270 zipped_grads = [theano.shared(p.get_value() * numpy_floatX(0.),
271 name='%s_grad' % k)
272 for k, p in tparams.items()]
273 running_up2 = [theano.shared(p.get_value() * numpy_floatX(0.),
274 name='%s_rup2' % k)
275 for k, p in tparams.items()]
276 running_grads2 = [theano.shared(p.get_value() * numpy_floatX(0.),
277 name='%s_rgrad2' % k)
278 for k, p in tparams.items()]
279
280 zgup = [(zg, g) for zg, g in zip(zipped_grads, grads)]
281 rg2up = [(rg2, 0.95 * rg2 + 0.05 * (g ** 2))
282 for rg2, g in zip(running_grads2, grads)]
283
284 f_grad_shared = theano.function([x, mask, y], cost, updates=zgup + rg2up,
285 name='adadelta_f_grad_shared')
286
287 updir = [-tensor.sqrt(ru2 + 1e-6) / tensor.sqrt(rg2 + 1e-6) * zg
288 for zg, ru2, rg2 in zip(zipped_grads,
289 running_up2,
290 running_grads2)]
291 ru2up = [(ru2, 0.95 * ru2 + 0.05 * (ud ** 2))
292 for ru2, ud in zip(running_up2, updir)]
293 param_up = [(p, p + ud) for p, ud in zip(tparams.values(), updir)]
294
295 f_update = theano.function([lr], [], updates=ru2up + param_up,
296 on_unused_input='ignore',
297 name='adadelta_f_update')
298

Callers

nothing calls this directly

Calls 1

numpy_floatXFunction · 0.85

Tested by

no test coverage detected