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

ValueError raised upon calling RetVecTokenizer function #48

Open
chinsu70802 opened this issue May 7, 2024 · 3 comments
Open

ValueError raised upon calling RetVecTokenizer function #48

chinsu70802 opened this issue May 7, 2024 · 3 comments

Comments

@chinsu70802
Copy link

chinsu70802 commented May 7, 2024

Hi!

I am trying to use RetVec as an embedding layer for a email spam classification project. When the RetVecTokenizer function is called, I get a Value Error which is described below:

File format not supported: filepath=/root/.keras/retvec-v1. Keras 3 only supports V3 .keras files and legacy H5 format files (.h5 extension). Note that the legacy SavedModel format is not supported by load_model() in Keras 3. In order to reload a TensorFlow SavedModel as an inference-only layer in Keras 3, use keras.layers.TFSMLayer(/root/.keras/retvec-v1, call_endpoint='serving_default') (note that your call_endpoint might have a different name).

Here is the code I wrote:

inputs = layers.Input(shape=(1, ), name="token", dtype=tf.string)

lstm_1 = tf.keras.layers.LSTM(20, dropout=0.2, return_sequences=True)(x)
lstm_2 = tf.keras.layers.LSTM(20, dropout=0.2, return_sequences=True)(lstm_1)
flatten = tf.keras.layers.Flatten()(lstm_2)
dropout = tf.keras.layers.Dropout(0.2, name="dropout")(flatten)
dense = tf.keras.layers.Dense(1, activation="sigmoid")(dropout)

model = tf.keras.Model(inputs=[inputs], outputs=[dense])

How to resolve this?

@Jinnrry
Copy link

Jinnrry commented Jul 15, 2024

Same problem, I downgraded tensorflow to 2.7.4 to solve the problem.

@Jinnrry
Copy link

Jinnrry commented Jul 16, 2024

Addendum: 2.7.4 can train the model but cannot execute the prediction code, with 2.8.4 you can train as well as execute the prediction.

@chinsu70802
Copy link
Author

Thanks @Jinnrry! It is working now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants