You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/01/07 02:28:59 UTC

[GitHub] szha commented on a change in pull request #9323: support setattr for some specified paramter of ParameterDict

szha commented on a change in pull request #9323: support setattr for some specified paramter of ParameterDict
URL: https://github.com/apache/incubator-mxnet/pull/9323#discussion_r160039429
 
 

 ##########
 File path: python/mxnet/gluon/parameter.py
 ##########
 @@ -605,15 +605,27 @@ def setattr(self, name, value):
 
             model.collect_params().setattr('lr_mult', 0.5)
 
+        or set grad_req to null if you don't need gradient w.r.t  model's
+        Parameters in ['conv1_weight', 'conv1_bias']::
+
+            model.collect_params().setattr('grad_req', 'null', ['conv1_weight', 'conv1_bias'])
+
         Parameters
         ----------
         name : str
             Name of the attribute.
         value : valid type for attribute name
             The new value for the attribute.
+        selected_param_names : str or list
+            The selected paramters to be setattr.
         """
-        for i in self.values():
-            setattr(i, name, value)
+        if selected_param_names == "all":
+            selected_param_names = self.keys()
+        elif isinstance(selected_param_names, str):
+            selected_param_names = [selected_param_names]
 
 Review comment:
   "all" can be a valid parameter name.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services