Commit 0dabefa2 authored by Yuxin Wu's avatar Yuxin Wu

improve docs in StatMonitorParamSetter

parent 72d54fdc
...@@ -297,12 +297,15 @@ class StatMonitorParamSetter(HyperParamSetter): ...@@ -297,12 +297,15 @@ class StatMonitorParamSetter(HyperParamSetter):
last_k (int): last k epochs. last_k (int): last k epochs.
reverse (bool): monitor increasing instead of decreasing. reverse (bool): monitor increasing instead of decreasing.
This callback will change param by ``new_value = value_func(old_value)``, when: This callback will change ``param`` by ``new_value = value_func(old_value)``, when:
``min(stats) >= stats[0] - threshold``, where ``min(stats) >= stats[0] - threshold``, where
``stats = [stat_name in last k epochs]`` ``stats = [the values of stat_name in last k epochs]``
If ``reverse`` is True, it will change the ``param`` when:
``max(stats) <= stats[0] + threshold``.
Example: Example:
If validation error wasn't decreasing for 5 epochs, anneal the learning rate: If validation error wasn't decreasing for 5 epochs, anneal the learning rate by 0.2:
.. code-block:: python .. code-block:: python
...@@ -334,6 +337,7 @@ class StatMonitorParamSetter(HyperParamSetter): ...@@ -334,6 +337,7 @@ class StatMonitorParamSetter(HyperParamSetter):
if hist_max > hist_first + self.threshold: # large enough if hist_max > hist_first + self.threshold: # large enough
return None return None
self.last_changed_epoch = self.epoch_num self.last_changed_epoch = self.epoch_num
logger.info("[StatMonitorParamSetter] Triggered, history: " + logger.info(
','.join(map(str, hist))) "[StatMonitorParamSetter] Triggered, history of {}: ".format(
self.stat_name) + ','.join(map(str, hist)))
return self.value_func(self.get_current_value()) return self.value_func(self.get_current_value())
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