Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ONNX node names should not have leading slash #1735

Open
mooskagh opened this issue Apr 21, 2022 · 3 comments
Open

ONNX node names should not have leading slash #1735

mooskagh opened this issue Apr 21, 2022 · 3 comments

Comments

@mooskagh
Copy link
Member

Apparently, Keras doesn't like such onnx files, giving the error:

ValueError: '/inputconv_pad/' is not a valid root scope name. A root scope name has to match the following pattern: ^[A-Za-z0-9.][A-Za-z0-9_.\\/>-]*$

Fix is this:
Remove trailing slashes in this file https://github.com/LeelaChessZero/lc0/blob/master/src/neural/onnx/converter.cc
(basically, replace all "/ which are not part of + "/ with ").

@mooskagh mooskagh added bug Something isn't working good first issue Good for newcomers labels Apr 21, 2022
@mooskagh
Copy link
Member Author

mooskagh commented Apr 21, 2022

Code to repro keras error:

from onnx2keras import onnx_to_keras
import onnx
onnx_model = onnx.load("generated_network.onnx")
onnx_to_keras(onnx_model, ['/input/planes'])

@mooskagh
Copy link
Member Author

After removing leading slashes, next error is

ValueError: Layer block0/conv2/se/matmul1 weight shape (1, 32) is not compatible with provided weight shape (384, 32).

It seems that onnx2keras just doesn't understand onnx well, I'm inclined not to push the slash removal (https://github.com/mooskagh/lc0/tree/onnx_slash) either.

@mooskagh mooskagh removed bug Something isn't working good first issue Good for newcomers labels Apr 23, 2022
@mooskagh
Copy link
Member Author

I considered filing bugs in the onnx2keras repo, but the projects doesn't look alive, last commit was a year ago, probably not worth it.

https://github.com/gmalivenko/onnx2keras

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

No branches or pull requests

1 participant