AutoViML / deep_autoviml

Build tensorflow keras model pipelines in a single line of code. Now with mlflow tracking. Created by Ram Seshadri. Collaborators welcome. Permission granted upon request.
Apache License 2.0
120 stars 36 forks source link

How do you load model and cat_vocab_dict after training? #2

Closed coderdoufu closed 3 years ago

coderdoufu commented 3 years ago

Thanks for your contributions! I have trained my model and I would like to know if there is anyway to load the trained from my saved_path?

coderdoufu commented 3 years ago

Whenever I tried to load the model from my saved_model path, I will always receive this message:

ValueError: Unable to restore custom object of type _tf_keras_metric currently. Please make sure that the layer implementsget_configandfrom_configwhen saving. In addition, please use thecustom_objectsarg when callingload_model().

AutoViML commented 3 years ago

very simple. Your model is saved under the project_name folder in .pb (protobuf) format which is the new Tensorflow saved model format.

You can load the model back if you give the project_name folder. It will automatically find the saved model and load associated artifacts which will help in predictions. The keras_model_type below is the same as the type of model that you built above (earlier). That way, you can have multiple model types under different names. The model and cat_vocab_dict are not needed and you can set them as empty strings.

Here is the call: y_preds = deep.predict(model="", project_name, test_dataset=test, keras_model_type=keras_model_type, cat_vocab_dict="")

If you still having trouble with it, please send an email to the email address in this Github with your details and we will fix it. Please make sure you do: pip install deep_autoviml --upgrade before you send the email and testing it with the latest version.