Exporting your models
The best model found by AutoKeras can be easily exported as a Keras model.
When saving your models to disk, this can be done in two different formats: the TensorFlow SavedModel format, and the older Keras H5 format. The recommended format is SavedModel, and this is the option used by default when we call to model.save()
.
How to save and load a model
Let's now see how to export and restore a model step by step:
- Export the model to a Keras model using the following code block:
model = my_autokeras_model.export_model()
Now, try to save to the TensorFlow format using the h5 format as backup as something is wrong:
try: model.save("model_autokeras", save_format="tf") except: model.save("model_autokeras.h5")
- Reload the model, as shown in the following code block:
from tensorflow.keras.models import load_model loaded_model = load_model("model_autokeras", custom_objects...