Unverified Commit bcf85026 authored by Kuro Latency's avatar Kuro Latency Committed by GitHub
Browse files

Update lr_updater.py (#574)

* Update lr_updater.py

since epoch/iteration in  runner starts with 0, we shouldn't leave the latter iteration to former (12th epoch for example, with first period equal to 12) period.

* Update lr_updater.py

* Update test_hooks.py
parent 66e249a0
......@@ -308,7 +308,7 @@ def get_position_from_periods(iteration, cumulative_periods):
For example, the cumulative_periods = [100, 200, 300, 400],
if iteration == 50, return 0;
if iteration == 210, return 2;
if iteration == 300, return 2.
if iteration == 300, return 3.
Args:
iteration (int): Current iteration.
......@@ -318,7 +318,7 @@ def get_position_from_periods(iteration, cumulative_periods):
int: The position of the right-closest number in the period list.
"""
for i, period in enumerate(cumulative_periods):
if iteration <= period:
if iteration < period:
return i
raise ValueError(f'Current iteration {iteration} exceeds '
f'cumulative_periods {cumulative_periods}')
......
......@@ -291,7 +291,7 @@ def test_cosine_restart_lr_update_hook():
'momentum': 0.95
}, 1),
call('train', {
'learning_rate': 0.0,
'learning_rate': 0.01,
'momentum': 0.95
}, 6),
call('train', {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment