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

When loaded a saved model from disk, predict is missing #25

Closed Howard-ll closed 3 years ago

Howard-ll commented 3 years ago

Hi

AttributeError: '_UserObject' object has no attribute 'predict'

Thanks!

achoum commented 3 years ago

TLDR

Try replacing

loaded_model = tf.saved_model.load(file_name)

by

loaded_model = tf.keras.models.load_model(file_name)

Details

The predict method is not part of the TensorFlow SavedModel object itself. Instead, it is created and restored by Keras (which is build on top of TensorFlow). If you work work with Keras models, it is best to load them with tf.keras.models.load_model.

Howard-ll commented 3 years ago
tf.keras.models.load_model

Thanks! You are right.