szha commented on a change in pull request #18619:
URL: https://github.com/apache/incubator-mxnet/pull/18619#discussion_r455391942
##########
File path: python/mxnet/gluon/block.py
##########
@@ -1620,29 +1602,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 we should probably include two switches to detect parameter set
mismatch, ignore_extra_param and ignore_missing_param, with both default to
False. if either case happens, we should raise ValueError with the complete
information on what's extra and what's missing. Warning will often be visual
noise that people ignore.
----------------------------------------------------------------
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:
[email protected]