Can not predict with exported model.
See original GitHub issueBug Description
After fitting my autokeras model, I export it, however, I can not predict nor evaluate with this exported Keras model.
from tensorflow.keras.datasets import mnist
(x_train, y_train), (x_test, y_test) = mnist.load_data()
x_train.shape # (60000, 28, 28)
y_train.shape # (60000,)
y_train[:3] # array([7, 2, 1], dtype=uint8)
x_train = x_train[:1000]
x_test = x_test[:1000]
y_train = y_train[:1000]
y_test = y_test[:1000]
import autokeras as ak
clf = ak.ImageClassifier(max_trials=3, directory = "/tmp/")
clf.fit(x_train, y_train, epochs=3)
predicted_y = clf.predict(x_test)
clf.evaluate(x_test, y_test)
model = clf.export_model()
predicted_y_2 = model.predict(x_test)
# ValueError: Error when checking input: expected input_1 to have 4 dimensions, but got array with shape (1000, 28, 28)
model.evaluate(x_test, y_test)
# ValueError: Error when checking input: expected input_1 to have 4 dimensions, but got array with shape (1000, 28, 28)
Setup Details
Include the details about the versions of:
- OS type and version: Ubuntu 18.04
- Python: Python 3.6.10
- autokeras: 1.0.0
- numpy: 1.18.1
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (8 by maintainers)
Top Results From Across the Web
Export Regression Model to Predict New Data - MathWorks
To exclude the training data, click Export Model and select Export Compact Model. This option exports the model with unnecessary data removed. That...
Read more >keras - Autokeras exported model performs not as expected
But when I export and save it as a keras model the model performs really bad. It classifies everything wrongly and the predict-function...
Read more >Exporting models for prediction - AI Platform - Google Cloud
To serve predictions from AI Platform Prediction, you must export your trained machine learning model as one or more artifacts. This guide describes...
Read more >2. Exporting and deploying a model — IPU TensorFlow ...
For non-Keras models, the export method does not accept the batch-size parameter. ... The function is the same predict function that was exported...
Read more >Export TensorFlow models in the SavedModel format
The assets directory is optional. It stores supporting files for the prediction service. The variables directory stores the variables saved by ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi, before you train on
x_train
andy_train
and test onx_test
, did you expand a dimension to the last dimension ofx_train
andx_test
and make it have a shape of(None, 28, 28, 1)
?That’s usually how people do on the datasets to train and test the CNNs with the regular TensorFlow/Keras.
@zhulingchen Would you like to do a user study with us? Have a 30-minute meeting with me to talk about what do you think of AutoKeras. Your thinking is important to us. Thanks.