<jupyter_start><jupyter_text>Load MNIST dataset<jupyter_code>from tensorflow.keras.datasets import mnist
(x_train, y_train), (x_test, y_test) = mnist.load_data()
print('Training image shape:', x_train.shape) # (60000, 28, 28)
print('Training label shape:', y_train.shape) # (60000,)
print('First five training labels:', y_train[:5]) # array([5 0 4 1 9], dtype=uint8)<jupyter_output><empty_output><jupyter_text>IO API for image classification<jupyter_code>import autokeras as ak

# Initialize the IO API.
io_model = ak.AutoModel(
    inputs = ak.ImageInput(),
    outputs = ak.ClassificationHead(loss='categorical_crossentropy', metrics=['accuracy']),
    objective = 'val_loss',
    tuner = 'random',
    max_trials=3)

# Fit the model with prepared data.
io_model.fit(x_train, y_train, epochs=10, verbose=2)<jupyter_output><empty_output><jupyter_text>Get the summarized results during the tuning process (return the best 10 models if existed)<jupyter_code>io_model.tuner.results_summary()<jupyter_output><empty_output><jupyter_text>Retrieve best model<jupyter_code>best_model = io_model.export_model()
best_model.summary()<jupyter_output><empty_output><jupyter_text>Predict with the best model.<jupyter_code>predicted_y = io_model.predict(x_test)
print(predicted_y)<jupyter_output><empty_output><jupyter_text>Evaluate the best model on the test data.<jupyter_code>test_loss, test_acc = io_model.evaluate(x_test, y_test, verbose=0)
print('Test accuracy: ', test_acc)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12098930481283422, 'fraction_numerical': 0.01871657754010695, 'mean_word_length': 8.298136645962733, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '561845', 'license': 'MIT', 'n_tokens_mistral': 566, 'n_tokens_neox': 533, 'n_words': 105, 'path': '4.4.1-IO-API-Image-Classification.ipynb', 'repo_name': 'datamllab/automl-in-action-notebooks', 'size': '1496'}