Skip to content

Instantly share code, notes, and snippets.

@LetticiaNicoli
Created September 14, 2019 12:46
Show Gist options
  • Save LetticiaNicoli/d43d1270b3ddec4391171576c7011483 to your computer and use it in GitHub Desktop.
Save LetticiaNicoli/d43d1270b3ddec4391171576c7011483 to your computer and use it in GitHub Desktop.
AutoKeras Demo
!pip install autokeras
!pip install keras
from keras.datasets import mnist
from autokeras.image.image_supervised import ImageClassifier
# loadning fashion-mnist from keras
(X_train, y_train), (X_test, y_test) = fashion_mnist.load_data()
X_train = X_train.reshape(X_train.shape + (1,))
X_test = X_test.reshape(X_test.shape + (1,))
# initialize the classifier
# data augmentation set to True
clf_augmented = ImageClassifier(verbose=True, augment=True)
# fit the classifier to the dataset
# nb!: default time limit is 24 h!
# for this example 1 h should be enough
clf_augmented.fit(X_train, y_train, time_limit=(1*60*60))
clf_augmented.final_fit(X_train, y_train, X_test, y_test, retrain=False)
y_pred_augmented = clf_augmented.evaluate(X_test, y_test)
print(y_pred_augmented)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment