-
Notifications
You must be signed in to change notification settings - Fork 19.6k
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
ValueErrors when calling Model.export() for TF SavedModel format on Keras Models with dict inputs #20835
Labels
Comments
When this is fixed the follow should work (and would make a good unit test on the tf backend). inputs = {
"foo": keras.Input(shape=()),
"bar": keras.Input(shape=()),
}
outputs = keras.layers.Add()([inputs["foo"], inputs["bar"]])
model = keras.Model(inputs, outputs)
model.export("test/", format="tf_saved_model") |
Apologies for the delay. I’ve been occupied with another PR and haven’t been able to make progress on this. Since time is of the essence, it’s now open for other contributors to work on. If no one picks it up, I’ll resume once my current PR is wrapped up. Thanks for your patience! |
hertschuh
added a commit
to hertschuh/keras
that referenced
this issue
Mar 27, 2025
Fixes keras-team#20835 Also changed multi-input tests to exercise `model.export()` and its signature inference logic.
hertschuh
added a commit
to hertschuh/keras
that referenced
this issue
Mar 27, 2025
Fixes keras-team#20835 Also changed multi-input tests to exercise `model.export()` and its signature inference logic.
fchollet
pushed a commit
that referenced
this issue
Mar 27, 2025
Fixes #20835 Also changed multi-input tests to exercise `model.export()` and its signature inference logic.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Problem
The
Model.export()
API in Keras 3 supports exporting to a TensorFlow SavedModel artifact for inference. When trying to export Gemma 2 and ShieldGemma to TF SavedModel, I ran into two differentValueError
s:input_signature
is provided, aValueError
will be thrown related to a structural mismatch between the expected and actual inputs passed to theGemmaCausalLM
class; andinput_signature
is provided as alist[keras.InputSpec]
, aValueError
will be thrown related the the wrong number of values being passed to a TF function.However, if yo uwrap the
dict
frommodel.input
in alist
, asinput_signature=[model.input]
, the export runs to completion.This is not restricted to Gemma models, as shown in this minimal reproducible example.
Thanks to @mattdangerw for helping to isolate this minimal example.
The text was updated successfully, but these errors were encountered: