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