retvec icon indicating copy to clipboard operation
retvec copied to clipboard

ValueError raised upon calling RetVecTokenizer function

Open chinsu70802 opened this issue 1 year ago • 3 comments

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?

chinsu70802 avatar May 07 '24 06:05 chinsu70802

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

Jinnrry avatar Jul 15 '24 08:07 Jinnrry

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.

Jinnrry avatar Jul 16 '24 03:07 Jinnrry

Thanks @Jinnrry! It is working now.

chinsu70802 avatar Jul 16 '24 03:07 chinsu70802