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

Class RMSprop

lib/updates.py:118–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116
117
118class RMSprop(Update):
119
120 def __init__(self, lr=0.001, rho=0.9, epsilon=1e-6, *args, **kwargs):
121 Update.__init__(self, *args, **kwargs)
122 self.__dict__.update(locals())
123
124 def __call__(self, params, cost):
125 updates = []
126 grads = T.grad(cost, params)
127 grads = clip_norms(grads, self.clipnorm)
128 for p,g in zip(params,grads):
129 g = self.regularizer.gradient_regularize(p, g)
130 acc = theano.shared(p.get_value() * 0.)
131 acc_new = self.rho * acc + (1 - self.rho) * g ** 2
132 updates.append((acc, acc_new))
133
134 updated_p = p - self.lr * (g / T.sqrt(acc_new + self.epsilon))
135 updated_p = self.regularizer.weight_regularize(updated_p)
136 updates.append((p, updated_p))
137 return updates
138
139
140class Adam(Update):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected