Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Potential solution for KeyError problems #20799

Open
gospodima opened this issue Dec 29, 2021 · 1 comment
Open

Potential solution for KeyError problems #20799

gospodima opened this issue Dec 29, 2021 · 1 comment

Comments

@gospodima
Copy link

Description

I had the same error as described in several issues here: #18923, #16590, #20317 and here
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:

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:

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.

@gcunhase
Copy link

Any update on this?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants