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



##########
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:
       There's the risk that users misuse the API by mistake and don't see the 
warning (eg. CI server often doesn't error out for warnings). So IMO it's 
better to enforce a high standard and ensure that users don't pass an invalid 
parameter dict. If they do so by mistake and don't see the warning, they end up 
with randomly initialized parameters instead of the intended values.




----------------------------------------------------------------
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