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

TF saved model, can we predict without converting to ELWC first? #302

Open
RodrigoVillatoro opened this issue Nov 25, 2021 · 0 comments
Open

Comments

@RodrigoVillatoro
Copy link

RodrigoVillatoro commented Nov 25, 2021

I trained and saved a TF model following the approach found here: https://github.com/tensorflow/ranking/blob/master/tensorflow_ranking/examples/keras/antique_kpl_din.py

The model is saved this way:

model.save(
      filepath=saved_model_path,
      signatures=tfr.keras.saved_model.Signatures(
          model,
          context_feature_spec=context_feature_spec,
          example_feature_spec=example_feature_spec,
          mask_feature_name=_MASK)())

Later to predict I do the following:

loaded_model = tf.saved_model.load(saved_model_path)
predict_function = loaded_model.signatures['tensorflow/serving/predict']
ELWC = convert_to_elwc(df_to_rank)
predictions = predict_function(inputs=tf.convert_to_tensor([ELWC.SerializeToString()]))

The convert_to_elwc function takes a pandas dataframe and converts it to a ELWC proto by iterating on each of the examples. My question: is there a way to skip this conversion? (i.e. take the original dataframe.values and pass them to the model directly)?

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

1 participant