leezu commented on a change in pull request #18619: URL: https://github.com/apache/incubator-mxnet/pull/18619#discussion_r455201489
########## 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 you are referring to the case where users would like to only export part of their HybridBlock to Symbol. We should better support this case in the `HybridBlock.export` function. For the case that users manually modify the Symbol and remove choose some of the outputs only (eg based on `list_internals()`), they can also prune the parameter dict via `param = {n:p for n,p in params.items() if n in s.list_inputs()}` ---------------------------------------------------------------- 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