You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@mxnet.apache.org by GitBox <gi...@apache.org> on 2021/12/29 18:43:07 UTC

[GitHub] [incubator-mxnet] gospodima opened a new issue #20799: Potential solution for KeyError problems

gospodima opened a new issue #20799:
URL: https://github.com/apache/incubator-mxnet/issues/20799


   ## Description
   I had the same error as described in several issues here: #18923, #16590, #20317 and [here](https://github.com/onnx/onnx-mxnet/issues/54)
   By investigating the code, I came up with an idea that the probable problem of the KeyError issues is that during inputs initialization only `self._nodes` are considered (where graph inputs and node outputs are stored), however, some inputs can be also stored in initializer according to onnx [documentation](https://github.com/onnx/onnx/blob/master/docs/IR.md):
   
   > Names of the values used by the node to propagate input values to the node operator. It must refer to either a graph input, a graph initializer or a node output. 
   
   I tried to replace `inputs = [self._nodes[i] for i in node.input]` with:
   ```python
   inputs = []
   for i in node.input:
       try:
           inputs.append(self._nodes[i])
       except KeyError:
           inputs.append(symbol.Variable(name=i, shape=self._params[i].shape))
   ```
   And it looks like import is successfull then (i.e. all not found keys are actually found in params). But of course I don't initialize variable weights here. Unfortunately, I am not really advanced with mxnet and couldn't find a working way to initialize `symbol.Variable` with `NDArray`.
   
   If it is possible to initialize variable with an array, it might be a working solution for this issue.


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

To unsubscribe, e-mail: issues-unsubscribe@mxnet.apache.org

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



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@mxnet.apache.org
For additional commands, e-mail: issues-help@mxnet.apache.org