forked from facebookresearch/fvcore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Exponential Parameter Scheduler (#715)
Summary: Pull Request resolved: facebookresearch/ClassyVision#715 Exponential parameter scheduler for fvcore/ClassyVision. This type of scheduler is useful as a LR scheduler when using EMA. Differential Revision: D27058657 fbshipit-source-id: 176ee5bcd074d5d517afa660a7dbf86f83468979
- Loading branch information
1 parent
1f43d07
commit e16b3e8
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Copyright (c) Facebook, Inc. and its affiliates. | ||
|
||
import unittest | ||
|
||
from fvcore.common.param_scheduler import ExponentialParamScheduler | ||
|
||
|
||
class TestExponentialScheduler(unittest.TestCase): | ||
_num_epochs = 10 | ||
|
||
def _get_valid_config(self): | ||
return {"start_value": 2.0, "decay": 0.1} | ||
|
||
def _get_valid_intermediate_values(self): | ||
return [1.5887, 1.2619, 1.0024, 0.7962, 0.6325, 0.5024, 0.3991, 0.3170, 0.2518] | ||
|
||
def test_scheduler(self): | ||
config = self._get_valid_config() | ||
|
||
scheduler = ExponentialParamScheduler(**config) | ||
schedule = [ | ||
round(scheduler(epoch_num / self._num_epochs), 4) | ||
for epoch_num in range(self._num_epochs) | ||
] | ||
expected_schedule = [ | ||
config["start_value"] | ||
] + self._get_valid_intermediate_values() | ||
|
||
self.assertEqual(schedule, expected_schedule) |