MCPcopy Create free account
hub / github.com/lazyprogrammer/machine_learning_examples / momentum_updates

Function momentum_updates

nlp_class2/glove_theano.py:27–38  ·  view source on GitHub ↗
(cost, params, lr=1e-4, mu=0.9)

Source from the content-addressed store, hash-verified

25
26
27def momentum_updates(cost, params, lr=1e-4, mu=0.9):
28 grads = T.grad(cost, params)
29 velocities = [theano.shared(
30 np.zeros_like(p.get_value()).astype(np.float32)
31 ) for p in params]
32 updates = []
33 for p, v, g in zip(params, velocities, grads):
34 newv = mu*v - lr*g
35 newp = p + newv
36 updates.append((p, newp))
37 updates.append((v, newv))
38 return updates
39
40
41class Glove:

Callers 1

fitMethod · 0.70

Calls 1

gradMethod · 0.45

Tested by

no test coverage detected