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

Method test_AdaGrad_const_lr

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

Source from the content-addressed store, hash-verified

129
130 @on_cpu_gpu
131 def test_AdaGrad_const_lr(self, dev=cpu_dev):
132 cpu_dev.EnableGraph(False)
133 opt1 = opt.AdaGrad(lr=0.1)
134 w_shape=(2,3)
135 w = tensor.Tensor(w_shape, device=dev).set_value(0.1)
136 g = tensor.Tensor(w_shape, device=dev).set_value(0.1)
137
138 # history = history + param_grad * param_grad
139 # param_value = param_value - lr * param_grad / sqrt(history + epsilon)
140
141 history = tensor.square(g)
142 tmp = history + 1e-8
143 tmp = tensor.sqrt(tmp)
144 tmp = g / tmp
145
146 w_step1 = w - 0.1 * tmp
147 opt1.apply(w.name, w, g)
148
149 assertTensorEqual(w, w_step1)
150
151 @on_cpu_gpu
152 def test_Adam_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