Skip to content

Commit fbca29b

Browse files
committed
update: test_ranger21_warm_up_and_down
1 parent 1204ca7 commit fbca29b

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

tests/test_optimizer_parameters.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,25 @@ def test_safe_fp16_methods():
244244
assert optimizer.loss_scale == 2.0 ** (15 - 1)
245245

246246

247-
def test_ranger21_warm_methods():
247+
def test_ranger21_warm_iterations():
248248
assert Ranger21.build_warm_up_iterations(1000, 0.999) == 220
249249
assert Ranger21.build_warm_up_iterations(4500, 0.999) == 2000
250250
assert Ranger21.build_warm_down_iterations(1000) == 280
251251

252252

253+
def test_ranger21_warm_up_and_down():
254+
param = simple_parameter(require_grad=False)
255+
256+
lr: float = 1e-1
257+
opt = Ranger21([param], num_iterations=500, lr=lr, warm_down_min_lr=3e-5)
258+
259+
assert opt.warm_up_dampening(lr, 100) == 0.09090909090909091
260+
assert opt.warm_up_dampening(lr, 200) == 0.1
261+
assert opt.warm_up_dampening(lr, 300) == 0.1
262+
assert opt.warm_down(lr, 300) == 0.1
263+
assert opt.warm_down(lr, 400) == 0.07093070921985817
264+
265+
253266
@pytest.mark.parametrize('optimizer', ['ranger21', 'adai'])
254267
def test_size_of_parameter(optimizer):
255268
param = simple_parameter(require_grad=False)

0 commit comments

Comments
 (0)