MCPcopy Create free account
hub / github.com/apache/singa / test_RMSProp_const_lr

Method test_RMSProp_const_lr

test/python/test_opt.py:110–128  ·  view source on GitHub ↗
(self, dev=cpu_dev)

Source from the content-addressed store, hash-verified

108
109 @on_cpu_gpu
110 def test_RMSProp_const_lr(self, dev=cpu_dev):
111 cpu_dev.EnableGraph(False)
112 opt1 = opt.RMSProp(lr=0.1)
113 w_shape=(2,3)
114 w = tensor.Tensor(w_shape, device=dev).set_value(0.1)
115 g = tensor.Tensor(w_shape, device=dev).set_value(0.1)
116
117 # running_average = running_average * rho + param_grad * param_grad * (1 - rho)
118 # param_value = param_value - lr * param_grad / sqrt(running_average + epsilon)
119
120 running_average = 0.1 * tensor.square(g)
121 tmp = running_average + 1e-8
122 tmp = tensor.sqrt(tmp)
123 tmp = g / tmp
124
125 w_step1 = w - 0.1 * tmp
126 opt1.apply(w.name, w, g)
127
128 assertTensorEqual(w, w_step1)
129
130 @on_cpu_gpu
131 def test_AdaGrad_const_lr(self, dev=cpu_dev):

Callers

nothing calls this directly

Calls 5

applyMethod · 0.95
assertTensorEqualFunction · 0.85
EnableGraphMethod · 0.80
TensorMethod · 0.80
set_valueMethod · 0.45

Tested by

no test coverage detected