Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

support regex of collect_params() #9348

Merged
merged 12 commits into from
Jan 12, 2018
Prev Previous commit
Next Next commit
fix pylint
wuwei authored and tornadomeet committed Jan 12, 2018

Verified

This commit was signed with the committer’s verified signature. The key has been revoked.
eggplants haruna
commit dd2891657fae7b3dd8be7a2eda8809e737ff5b82
8 changes: 6 additions & 2 deletions python/mxnet/gluon/block.py
Original file line number Diff line number Diff line change
@@ -238,15 +238,19 @@ def collect_params(self, select=['.*']):

model.collect_params(['conv1_weight', 'conv1_bias'])

or collect all paramters which their name ends with 'weight' or 'bias', this can be done using
regular expressions::
or collect all paramters which their name ends with 'weight' or 'bias', this can be done
using regular expressions::

model.collect_params(['.*weight', '.*bias'])

Parameters
----------
select : list of str
List of name or regular expressions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only support 1 regex, not a list

Copy link
Contributor Author

@tornadomeet tornadomeet Jan 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. @piiswrong

another, if user has a python list to select parameter, like ['a', 'b', 'c'], t hen he/she should first convert select='a|b|c' first using some code, any better way to avoid this?


Returns
-------
The selected :py:class:`ParameterDict`
"""
ret = ParameterDict(self._params.prefix)
for s in select: