Skip to content

updated ReversibleEmbedding call method to handle proper conversion to tensors. #2295

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

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion keras_hub/src/layers/modeling/reversible_embedding.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,12 @@ def build(self, inputs_shape=None):
def call(self, inputs, reverse=False):
if reverse:
if self.tie_weights:
kernel = ops.transpose(ops.convert_to_tensor(self.embeddings))
# Ensure embeddings is properly converted to a tensor
embeddings_tensor = self.embeddings
# If it's a Keras variable, get its value
if hasattr(embeddings_tensor, "value"):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so what's the error here? embeddings_tensor has no value when tf numpy is enabled? what's the error?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keras-team/keras@9286df3

I am not able to reproduce the error, it has been fixed in the above commit on keras.

embeddings_tensor = embeddings_tensor.value
kernel = ops.transpose(ops.convert_to_tensor(embeddings_tensor))
else:
kernel = self.reverse_embeddings
if self.reverse_dtype is not None:
Expand Down
Loading