Unverified Commit f5be29b2 authored by Harry's avatar Harry Committed by GitHub
Browse files

fix: fix constructor docstring (#328)

parent 821b3ad6
...@@ -10,6 +10,7 @@ from .builder import OPTIMIZER_BUILDERS, OPTIMIZERS ...@@ -10,6 +10,7 @@ from .builder import OPTIMIZER_BUILDERS, OPTIMIZERS
@OPTIMIZER_BUILDERS.register_module() @OPTIMIZER_BUILDERS.register_module()
class DefaultOptimizerConstructor(object): class DefaultOptimizerConstructor(object):
"""Default constructor for optimizers. """Default constructor for optimizers.
By default each parameter share the same optimizer settings, and we By default each parameter share the same optimizer settings, and we
provide an argument ``paramwise_cfg`` to specify parameter-wise settings. provide an argument ``paramwise_cfg`` to specify parameter-wise settings.
It is a dict and may contain the following fields: It is a dict and may contain the following fields:
...@@ -26,7 +27,8 @@ class DefaultOptimizerConstructor(object): ...@@ -26,7 +27,8 @@ class DefaultOptimizerConstructor(object):
decay for all weight and bias parameters of depthwise conv decay for all weight and bias parameters of depthwise conv
layers. layers.
- ``bypass_duplicate`` (bool): If true, the duplicate parameters - ``bypass_duplicate`` (bool): If true, the duplicate parameters
would not be added into optimizer. Default: False would not be added into optimizer. Default: False.
Args: Args:
model (:obj:`nn.Module`): The model with parameters to be optimized. model (:obj:`nn.Module`): The model with parameters to be optimized.
optimizer_cfg (dict): The config dict of the optimizer. optimizer_cfg (dict): The config dict of the optimizer.
...@@ -36,6 +38,7 @@ class DefaultOptimizerConstructor(object): ...@@ -36,6 +38,7 @@ class DefaultOptimizerConstructor(object):
- any arguments of the corresponding optimizer type, e.g., - any arguments of the corresponding optimizer type, e.g.,
lr, weight_decay, momentum, etc. lr, weight_decay, momentum, etc.
paramwise_cfg (dict, optional): Parameter-wise options. paramwise_cfg (dict, optional): Parameter-wise options.
Example: Example:
>>> model = torch.nn.modules.Conv1d(1, 1, 1) >>> model = torch.nn.modules.Conv1d(1, 1, 1)
>>> optimizer_cfg = dict(type='SGD', lr=0.01, momentum=0.9, >>> optimizer_cfg = dict(type='SGD', lr=0.01, momentum=0.9,
...@@ -79,8 +82,10 @@ class DefaultOptimizerConstructor(object): ...@@ -79,8 +82,10 @@ class DefaultOptimizerConstructor(object):
def add_params(self, params, module, prefix=''): def add_params(self, params, module, prefix=''):
"""Add all parameters of module to the params list. """Add all parameters of module to the params list.
The parameters of the given module will be added to the list of param The parameters of the given module will be added to the list of param
groups, with specific rules defined by paramwise_cfg. groups, with specific rules defined by paramwise_cfg.
Args: Args:
params (list[dict]): A list of param groups, it will be modified params (list[dict]): A list of param groups, it will be modified
in place. in place.
......
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