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

load_model no longer works with Dot layer in TensorFlow 2.16 #65056

Closed
Dobiasd opened this issue Apr 4, 2024 · 4 comments
Closed

load_model no longer works with Dot layer in TensorFlow 2.16 #65056

Dobiasd opened this issue Apr 4, 2024 · 4 comments
Assignees
Labels
comp:keras Keras related issues stat:awaiting response Status - Awaiting response from author TF 2.16 type:support Support issues

Comments

@Dobiasd
Copy link

Dobiasd commented Apr 4, 2024

With TensorFlow 2.15.1, the following code works fine:

from tensorflow.keras.layers import Input, Dot
from tensorflow.keras.models import Model, load_model

input_1 = Input(shape=(2, 3, 4))
input_2 = Input(shape=(2, 3, 4))
x = Dot(axes=(1, 1))([input_1, input_2])
model = Model(inputs=[input_1, input_2], outputs=[x])
model.compile()
model.save('model.keras')

load_model('model.keras')

However, with TensorFlow 2.16.1, load_model throws an exception:

ValueError: A `Dot` layer should be called on a list of 2 inputs. Received: input_shape=[[None, 2, 3, 4], [None, 2, 3, 4]]
@tilakrayal tilakrayal added comp:keras Keras related issues TF 2.16 type:support Support issues labels Apr 4, 2024
@tilakrayal
Copy link
Contributor

@Dobiasd,
Yes, As you mentioned it was executed with the error on tensorflow v2.16 & keras 3.1.1. On tensorflow v2.15 it was executed without any error. And now it got fixed on tf-nightly(2.17.0-dev20240403) and keras(3.2.0.dev2024040303) which will be available in the upcoming releases.
Kindly find the attached gist for the reference.

Also there is PR raised for the similar issue in Keras repo which was merged recently.
keras-team/keras#19362

Thank you!

@tilakrayal tilakrayal added the stat:awaiting response Status - Awaiting response from author label Apr 4, 2024
@Dobiasd
Copy link
Author

Dobiasd commented Apr 4, 2024

Ok, perfect, thank you. 👍

@google-ml-butler google-ml-butler bot removed the stat:awaiting response Status - Awaiting response from author label Apr 4, 2024
@tilakrayal
Copy link
Contributor

@Dobiasd,
As this issue is resolved in tf-nightly, Could you please feel free to move this issue to closed status. Thank you!

@tilakrayal tilakrayal added the stat:awaiting response Status - Awaiting response from author label Apr 4, 2024
@Dobiasd Dobiasd closed this as completed Apr 4, 2024
Copy link

Are you satisfied with the resolution of your issue?
Yes
No

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:keras Keras related issues stat:awaiting response Status - Awaiting response from author TF 2.16 type:support Support issues
Projects
None yet
Development

No branches or pull requests

2 participants