tensorflow / decision-forests

A collection of state-of-the-art algorithms for the training, serving and interpretation of Decision Forest models in Keras.
Apache License 2.0
663 stars 110 forks source link

NotFoundError when load model from different device #14

Closed ihsanramdhani closed 3 years ago

ihsanramdhani commented 3 years ago

i got an error when load model using keras.models.load_model from different devices. This is my complete code: from tensorflow import keras model_path = '/content/drive/MyDrive/saved_model/my_model' imported = keras.models.load_model(model_path)

I got an error like this: NotFoundError: Op type not registered 'SimpleMLCreateModelResource' in binary running on 135bfc4bd927. Make sure the Op and Kernel are registered in the binary running in this process. Note that if you are loading a saved graph which used ops from tf.contrib, accessing (e.g.)tf.contrib.resamplershould be done before importing the graph, as contrib ops are lazily registered when the module is first accessed.

The training and evaluation was completed successfully

achoum commented 3 years ago

Thanks for the report.

Solution

Can you try importing TF-DF before loading the model?:

import tensorflow_decision_forests as tfdf
from tensorflow import keras

model_path = '/content/drive/MyDrive/saved_model/my_model'
imported = keras.models.load_model(model_path)

Explanation

TF-DF relies on a couple of TensorFlow custom ops. These ops need to be loaded manually (which happen when importing TF-DF).

ihsanramdhani commented 3 years ago

Its working!! Thanks

Koushik667 commented 3 years ago

Hello @achoum, i am getting the same errror when i save the model in python using model.save and then load the model using tensorflow C API. Can you please let me know if we can use tensorflow decsion forest model in C API?