Skip to content

Commit 4890aab

Browse files
committed
update: test_proportion_scheduler
1 parent 9995592 commit 4890aab

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

tests/test_lr_schedulers.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -110,18 +110,7 @@
110110
0.017247,
111111
0.019900,
112112
]
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)]
125114

126115

127116
@pytest.mark.parametrize('cosine_annealing_warmup_restart_param', CAWR_RECIPES)
@@ -192,14 +181,23 @@ def test_linear_warmup_poly_scheduler():
192181
np.testing.assert_almost_equal(expected_lr, lr, 6)
193182

194183

195-
def test_proportion_scheduler():
184+
@pytest.mark.parametrize('proportion_learning_rate', PROPORTION_LEARNING_RATES)
185+
def test_proportion_scheduler(proportion_learning_rate):
196186
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+
)
199197

200-
for expected_value in PP_RECIPE:
198+
for _ in range(10):
201199
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)
203201

204202

205203
def test_deberta_v3_large_lr_scheduler():

0 commit comments

Comments
 (0)