-
Notifications
You must be signed in to change notification settings - Fork 179
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
Sequential model runtime error #66
Comments
Hi @karloballa, I have tried your two ways of creating the model and for me it works fine in both ways. Maybe your models are being created with different operations names. Can you please show me the output of the command Also, you can use the function for (auto s: model.get_operations())
std::cout << s << std::endl; |
Thank you for the fast answer. I see there are some minor differences, but I don't know what they mean. model.get_operations(), Functional: dense/kernel model.get_operations(), Sequential: dense_2/kernel |
saved_model_cli , Functional: `Defined Functions: Function Name: '_default_save_signature' Function Name: 'call_and_return_all_conditional_losses' |
saved_model_cli , Sequential: Defined Functions: Function Name: '_default_save_signature' Function Name: 'call_and_return_all_conditional_losses' |
Hi @karloballa , I think the problem is that you are creating the two models one after the other from the same python script. In this way, when you create the second model, the name If that's your problem, just try to create one model from one script, and the other model from a different script. |
You were right. I made a new script and now it works for both APIs. The thing is that I'm not using Python for learning but Keras.Net and the problem I had was originally from the .net framework. I don't know for Python but in .net there are 2 ways to define an input layer. For example: smodel.Add(new Input(new Shape(inHeight, inWidth, inChannels))); smodel.Add(new Conv2D(8, new Tuple<int, int>(3, 3), padding: "same", activation: "relu", input_shape: new Shape(inHeight, inWidth, inChannels))); Now, Cppflow works fine with a model created as in 1), but give me a runtime error on a model created as in 2) I run get_operations() for both models and find 1 difference. I don't know if that matters, but as I said, the first model works, but the second doesn't. conv2d/kernel conv2d/kernel |
As you correctly pointed, that difference in the name is making the calling fail. When you just use To fix it, just specify the name of the input and the output that you want to use, as in the multi input output example: auto output = model({{"serving_default_conv2d_input:0", input}},{"StatefulPartitionedCall:0"}); |
It works now. Thank you! |
I'm new to Keras/Tensorflow framework, so my question may be silly.
I have the next problem. If I create a functional model:
input = tf.keras.Input(shape=(5,))
output = tf.keras.layers.Dense(5, activation=tf.nn.relu)(input)
output = tf.keras.layers.Dense(1, activation=tf.nn.sigmoid)(output)
model = tf.keras.Model(inputs=input, outputs=output)
model.compile()
model.save('model', save_format='tf')
then everything works fine.
When however I create the same model with the sequential API, I got the runtime error:
model = Sequential()
model.add(Input(shape=(5,)))
model.add(Dense(5))
model.add(Dense(1))
model.compile()
model.save('model', save_format='tf')
...
auto input = cppflow::fill({10, 5}, 1.0f);
cppflow::model model("model");
auto output = model(input); // << throw std::runtime_error("No operation named "" + op_name + "" exists");
Any help?
Thanks in advance
The text was updated successfully, but these errors were encountered: