acphile commented on a change in pull request #18619:
URL: https://github.com/apache/incubator-mxnet/pull/18619#discussion_r452119087



##########
File path: python/mxnet/gluon/block.py
##########
@@ -1573,29 +1534,31 @@ def __init__(self, outputs, inputs, params=None):
 
         arg_types, aux_types = _infer_param_types(syms, out, arg_params, 
aux_params)
 
-        def _set_params_attr(name, **kwargs):
-            if params.get(name) is None:
-                param = Parameter(**kwargs)
-                param._name = name
-            else:
-                param = params[name]
-                param._check_and_setattr(**kwargs)
-            if self._structured_named:
-                lis = structure[name]
-                assert len(lis) > 0, "Can not find structured name for 
Parameter %s in 'params'. " \
-                    "Please check 'params' is complete!" % name
-                for structured_name in lis:
-                    self._reg_params[structured_name] = param
-            else:
-                self._reg_params[name] = param
+        if params is None:
+            params = {}
+        unused_params = set(params.keys()) - set(arg_params) - set(aux_params)
+        if len(unused_params) > 0:
+            raise ValueError('{} params are unused by the 
model.'.format(unused_params))

Review comment:
       I think it is more reasonable to throw out a warning and remove unused 
parameters instead of raising a ValueError.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to