# NOT RUN {
library("keras")
# use the MNIST dataset as an example
mnist <- dataset_mnist()
c(x_train, y_train) %<-% mnist$train
c(x_test, y_test) %<-% mnist$test
library("autokeras")
# Initialize the image classifier
clf <- model_image_classifier(max_trials = 10) %>% # It tries 10 different models
fit(x_train, y_train) # Feed the image classifier with training data
# If you want to use own valitadion data do:
clf <- model_image_classifier(max_trials = 10) %>%
fit(
x_train,
y_train,
validation_data = list(x_test, y_test)
)
# Predict with the best model
(predicted_y <- clf %>% predict(x_test))
# Evaluate the best model with testing data
clf %>% evaluate(x_test, y_test)
# Get the best trained Keras model, to work with the keras R library
export_model(clf)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab