MCPcopy Create free account
hub / github.com/Newmu/dcgan_code / NAG

Class NAG

lib/updates.py:96–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94
95
96class NAG(Update):
97
98 def __init__(self, lr=0.01, momentum=0.9, *args, **kwargs):
99 Update.__init__(self, *args, **kwargs)
100 self.__dict__.update(locals())
101
102 def __call__(self, params, cost):
103 updates = []
104 grads = T.grad(cost, params)
105 grads = clip_norms(grads, self.clipnorm)
106 for p, g in zip(params, grads):
107 g = self.regularizer.gradient_regularize(p, g)
108 m = theano.shared(p.get_value() * 0.)
109 v = (self.momentum * m) - (self.lr * g)
110
111 updated_p = p + self.momentum * v - self.lr * g
112 updated_p = self.regularizer.weight_regularize(updated_p)
113 updates.append((m,v))
114 updates.append((p, updated_p))
115 return updates
116
117
118class RMSprop(Update):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected