Repository: open-mmlab/mmcv

Issue:
Typo in lr update hook
Is the class name [CosineAnealingLrUpdaterHook](https://github.com/open-mmlab/mmcv/blob/7cfc839ea5e6f395682f0af6c63f24500437cef5/mmcv/runner/hooks/lr_updater.py#L227) in `lr_updater`  misspelled?
It should be "Annealing", right?


Discussion:
Yes! It would be appreciated if you would like to open a PR to fix it.

Resolving patch:
diff --git a/mmcv/runner/base_runner.py b/mmcv/runner/base_runner.py
--- a/mmcv/runner/base_runner.py
+++ b/mmcv/runner/base_runner.py
@@ -313,7 +313,8 @@ def register_lr_hook(self, lr_config):
             # If the type of policy is all in lower case, e.g., 'cyclic',
             # then its first letter will be capitalized, e.g., to be 'Cyclic'.
             # This is for the convenient usage of Lr updater.
-            # Since this is not applicable for `CosineAnealingLrUpdater`,
+            # Since this is not applicable for `
+            # CosineAnnealingLrUpdater`,
             # the string will not be changed if it contains capital letters.
             if policy_type == policy_type.lower():
                 policy_type = policy_type.title()
@@ -333,7 +334,8 @@ def register_momentum_hook(self, momentum_config):
             # If the type of policy is all in lower case, e.g., 'cyclic',
             # then its first letter will be capitalized, e.g., to be 'Cyclic'.
             # This is for the convenient usage of momentum updater.
-            # Since this is not applicable for `CosineAnealingMomentumUpdater`,
+            # Since this is not applicable for
+            # `CosineAnnealingMomentumUpdater`,
             # the string will not be changed if it contains capital letters.
             if policy_type == policy_type.lower():
                 policy_type = policy_type.title()
diff --git a/mmcv/runner/hooks/lr_updater.py b/mmcv/runner/hooks/lr_updater.py
--- a/mmcv/runner/hooks/lr_updater.py
+++ b/mmcv/runner/hooks/lr_updater.py
@@ -224,13 +224,13 @@ def get_lr(self, runner, base_lr):
 
 
 @HOOKS.register_module()
-class CosineAnealingLrUpdaterHook(LrUpdaterHook):
+class CosineAnnealingLrUpdaterHook(LrUpdaterHook):
 
     def __init__(self, min_lr=None, min_lr_ratio=None, **kwargs):
         assert (min_lr is None) ^ (min_lr_ratio is None)
         self.min_lr = min_lr
         self.min_lr_ratio = min_lr_ratio
-        super(CosineAnealingLrUpdaterHook, self).__init__(**kwargs)
+        super(CosineAnnealingLrUpdaterHook, self).__init__(**kwargs)
 
     def get_lr(self, runner, base_lr):
         if self.by_epoch:
diff --git a/mmcv/runner/hooks/momentum_updater.py b/mmcv/runner/hooks/momentum_updater.py
--- a/mmcv/runner/hooks/momentum_updater.py
+++ b/mmcv/runner/hooks/momentum_updater.py
@@ -103,13 +103,13 @@ def before_train_iter(self, runner):
 
 
 @HOOKS.register_module()
-class CosineAnealingMomentumUpdaterHook(MomentumUpdaterHook):
+class CosineAnnealingMomentumUpdaterHook(MomentumUpdaterHook):
 
     def __init__(self, min_momentum=None, min_momentum_ratio=None, **kwargs):
         assert (min_momentum is None) ^ (min_momentum_ratio is None)
         self.min_momentum = min_momentum
         self.min_momentum_ratio = min_momentum_ratio
-        super(CosineAnealingMomentumUpdaterHook, self).__init__(**kwargs)
+        super(CosineAnnealingMomentumUpdaterHook, self).__init__(**kwargs)
 
     def get_momentum(self, runner, base_momentum):
         if self.by_epoch:


Test patch:
diff --git a/tests/test_runner/test_hooks.py b/tests/test_runner/test_hooks.py
--- a/tests/test_runner/test_hooks.py
+++ b/tests/test_runner/test_hooks.py
@@ -18,11 +18,11 @@
 
 from mmcv.runner import (EpochBasedRunner, IterTimerHook, MlflowLoggerHook,
                          PaviLoggerHook, WandbLoggerHook)
-from mmcv.runner.hooks.lr_updater import (CosineAnealingLrUpdaterHook,
+from mmcv.runner.hooks.lr_updater import (CosineAnnealingLrUpdaterHook,
                                           CosineRestartLrUpdaterHook,
                                           CyclicLrUpdaterHook)
 from mmcv.runner.hooks.momentum_updater import (
-    CosineAnealingMomentumUpdaterHook, CyclicMomentumUpdaterHook)
+    CosineAnnealingMomentumUpdaterHook, CyclicMomentumUpdaterHook)
 
 
 def test_pavi_hook():
@@ -101,7 +101,7 @@ def test_cosine_runner_hook():
     runner = _build_demo_runner()
 
     # add momentum scheduler
-    hook = CosineAnealingMomentumUpdaterHook(
+    hook = CosineAnnealingMomentumUpdaterHook(
         min_momentum_ratio=0.99 / 0.95,
         by_epoch=False,
         warmup_iters=2,
@@ -109,7 +109,7 @@ def test_cosine_runner_hook():
     runner.register_hook(hook)
 
     # add momentum LR scheduler
-    hook = CosineAnealingLrUpdaterHook(
+    hook = CosineAnnealingLrUpdaterHook(
         by_epoch=False, min_lr_ratio=0, warmup_iters=2, warmup_ratio=0.9)
     runner.register_hook(hook)
     runner.register_hook(IterTimerHook())
diff --git a/tests/test_runner/test_runner.py b/tests/test_runner/test_runner.py
--- a/tests/test_runner/test_runner.py
+++ b/tests/test_runner/test_runner.py
@@ -150,7 +150,7 @@ def test_build_lr_momentum_hook():
 
     # test policy that is already title
     lr_config = dict(
-        policy='CosineAnealing',
+        policy='CosineAnnealing',
         by_epoch=False,
         min_lr_ratio=0,
         warmup_iters=2,
@@ -200,7 +200,7 @@ def test_build_lr_momentum_hook():
 
     # test policy that is already title
     mom_config = dict(
-        policy='CosineAnealing',
+        policy='CosineAnnealing',
         min_momentum_ratio=0.99 / 0.95,
         by_epoch=False,
         warmup_iters=2,