-
Notifications
You must be signed in to change notification settings - Fork 179
libc++abi: terminating with uncaught exception of type std::runtime_error: No operation named "serving_default_input_1" exists #211
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
Comments
Hi @garricklw I don't fully understand what are you proposing. You mean matching the strings returned by |
I'll admit, I know almost nothing about which fields you can read from the model in cpp or how you're currently reading it, but the way load_model works in python Keras is if there is only one input layer in the whole model, it will automatically use that layer as input, regardless of how it's named. And I know at the very least the loaded Model in python provides the list of layers from which a reasonable default input layer could be picked, but that's all in python of course. I'm not sure what you mean by matching the string "input", do you mean looking through the layer names for the literal "string"? I guess what I'm saying is I would expect that the python Type of the layer (keras.layers.Input, keras.layers.Dense, etc...) would be readable somewhere in the saved model as python is able to read it, though I can't confirm that it's possible in cpp. |
Hi @garricklw I am sorry, but I don't know yet how to inspect the definition of the model to retrieve the default inputs and outputs. I guess it would require to somehow parse the MetaGraphDef obtained when doing |
#203 is a small step towards this |
Yeah, that's reasonable, my intuition for how easy it would be was just based on Python, so thanks for checking. Yeah, #203 seems like a good step for bridging the gap between the python code that builds the model and the cpp code calling it. The error message is only confusing because "serving_default_input_1" isn't explicitly defined anywhere in the model building, but I guess it's not that hard to figure out it's derived from the name of the input layer. |
Perhaps I could change the error generated when the operation is not found and suggest to use the |
I'd like to document an issue I ran into and the resolution in case anyone else runs into it, and to propose an api improvement, if possible, that would make the issue less difficult in the future.
I got the above error while trying to load a Keras model, and the resolution was that I needed to make sure the first layer of my model was named "input_1".
Keras has a singleton-esque pattern for naming its layers. That is, each time a layer of the same type is initialized in the same runtime, it increments the counter of the layer name. So the first time you create an input it's "input_1", the second time it's "input_2", etc...
This makes it really easy to make a model that throws the above error and not know exactly why it's happening. If it's possible, why not inspect the layers of the Keras model in cpp and use the first input layer as input by default, rather than looking for a hard-coded default name?
The text was updated successfully, but these errors were encountered: