|
110 | 110 | 0.017247, |
111 | 111 | 0.019900, |
112 | 112 | ] |
113 | | -PP_RECIPE = [ |
114 | | - 1.090909, |
115 | | - 1.090909, |
116 | | - 1.090909, |
117 | | - 1.090909, |
118 | | - 1.090909, |
119 | | - 1.090909, |
120 | | - 1.090909, |
121 | | - 1.090909, |
122 | | - 1.090909, |
123 | | - 1.090909, |
124 | | -] |
| 113 | +PROPORTION_LEARNING_RATES = [(1e-1, 1e-1, 2.0), (1e-1, 1e-3, 1.090909)] |
125 | 114 |
|
126 | 115 |
|
127 | 116 | @pytest.mark.parametrize('cosine_annealing_warmup_restart_param', CAWR_RECIPES) |
@@ -192,14 +181,23 @@ def test_linear_warmup_poly_scheduler(): |
192 | 181 | np.testing.assert_almost_equal(expected_lr, lr, 6) |
193 | 182 |
|
194 | 183 |
|
195 | | -def test_proportion_scheduler(): |
| 184 | +@pytest.mark.parametrize('proportion_learning_rate', PROPORTION_LEARNING_RATES) |
| 185 | +def test_proportion_scheduler(proportion_learning_rate): |
196 | 186 | base_optimizer = AdamP(Example().parameters()) |
197 | | - lr_scheduler = CosineScheduler(base_optimizer, t_max=10, max_lr=1e-1, min_lr=1e-3, init_lr=1e-2) |
198 | | - rho_scheduler = ProportionScheduler(lr_scheduler, max_lr=1e-1, min_lr=1e-3, max_value=2.0, min_value=1.0) |
| 187 | + lr_scheduler = CosineScheduler( |
| 188 | + base_optimizer, t_max=10, max_lr=proportion_learning_rate[0], min_lr=proportion_learning_rate[1], init_lr=1e-2 |
| 189 | + ) |
| 190 | + rho_scheduler = ProportionScheduler( |
| 191 | + lr_scheduler, |
| 192 | + max_lr=proportion_learning_rate[0], |
| 193 | + min_lr=proportion_learning_rate[1], |
| 194 | + max_value=2.0, |
| 195 | + min_value=1.0, |
| 196 | + ) |
199 | 197 |
|
200 | | - for expected_value in PP_RECIPE: |
| 198 | + for _ in range(10): |
201 | 199 | value = rho_scheduler.step() |
202 | | - np.testing.assert_almost_equal(expected_value, value, 6) |
| 200 | + np.testing.assert_almost_equal(proportion_learning_rate[2], value, 6) |
203 | 201 |
|
204 | 202 |
|
205 | 203 | def test_deberta_v3_large_lr_scheduler(): |
|
0 commit comments