(self, dev=cpu_dev)
| 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): |
nothing calls this directly
no test coverage detected