(self)
| 53 | |
| 54 | class TestDecayScheduler(unittest.TestCase): |
| 55 | def test_exponential_decay_cpu(self): |
| 56 | lr = opt.ExponentialDecay(0.1, 2, 0.5, True) |
| 57 | sgd1 = opt.SGD(lr=lr) |
| 58 | for i in range(5): |
| 59 | np.testing.assert_array_almost_equal(tensor.to_numpy(sgd1.lr_value), [0.1*0.5**(i//2)]) |
| 60 | sgd1.step() |
| 61 | |
| 62 | def test_exponential_decay_no_staircase_cpu(self): |
| 63 | lr = opt.ExponentialDecay(0.1, 2, 0.5, False) |