1

As you can see from this post, there is a problem with saving and loading autokeras models (please refer to the provided link for more details). I noticed that there are some binaries in the autokeras temporary folder (e.g. /tmp/autokeras_ECWBT7) which contains some binaries:

graph (1.graph, 2.graph, ...)

best_model.txt

classifier

module

temp_model

I could not find any documentation to see how can I use this to load the trained model (if there is any).

I will appreciate if you help me in this problem.

Ali
  • 387
  • 4
  • 11

1 Answers1

1

Autokeras really has a lack of documentation. I've found some ways how trained model may be used further (for autokeras version 0.3.7) in case of ImageClassifier:

  1. if you are using autokeras.image.image_supervised.ImageClassifier and want to continue searching models by using fit, or restart final_fit for the best model in your graph_directory, you can use this:

clf = ImageClassifier(verbose=True, augment=False, path='./path/to/graph/directory', resume=True)

  1. now you are able to continue net architecture search or export your best model. If you want to export your best model ImageClassifier and use it for prediction, you may use: clf.export_autokeras_model('your_model.pkl')

  2. and later you can load it that way:

from autokeras.utils import pickle_from_file

model = pickle_from_file('your_model.pkl')

and after that you are able to make predictions by: y_predict = model.predict(x_test)

It is suitable solution, if you want work exactly with Autokeras ImageClassifier model later (not convert it into something else).

SmartWaddles
  • 131
  • 2
  • 10
  • Thank you @SmartWaddles, yes I know that, I wanted it like keras model to use it and convert it to other formats as well. other than that, assuming autokeras gives the best model, I want to train it myself with keras for example which is not possible for this format. – Ali Mar 02 '19 at 13:27
  • 1
    @Ali, oh i see, in case of conversion to Keras, in version 0.3.7 you can use `ImageClassifier.export_keras_model('model.h5')`, but it has the same problem with 'manually compilation', as described in your linked post. However, you may try to compile it by using [link](https://keras.io/models/model/#compile). But there are a lot parameters to pass, and I have exactly the same problem - to pass them all in a right way. For loss `autokeras.nn.loss_function.classification_loss` may be used, but I don't know what with others. – SmartWaddles Mar 04 '19 at 10:39