
Article Co-authors with : @bonnefoypy and @emeric.chaize CEOs at Olexya.
Building the best model is a key step after exploratory data analysis and feature selection in any data science project. In deep learning this process consists of building layers by layers complexes neural networks (Perceptron, Vanilla, Convolutives, Recurrent) that will fit the data.
In most cases, the data need to be processed from images, voices, videos, text, and numbers into matrix formats. Finding innovative ways to obtain the best model and prediction in few lines of code is a tremendous advantage especially when classifying images for Computer Vision applications. Automate model selection methods for deep learning of images datasets generally include Autokeras and Azure studio.
To become a unicorn data scientist mastering the most recent Automate Neural Networks methods is a must-have skill. In this article, we will review the 2 best Kaggle winners’ Automate neural networks selections tools which can be implemented in an easy and fast manner.
- Autokeras
AutoKeras is an AutoML system based on Keras developed by DATA Lab at Texas A&M University. This framework can build a model with complex elements (embeddings, features augmentations, etc..) automatically pre-processing the data (text, images, numbers, categorical data) and finding the best neural architecture (numbers of layers, percent of dropout layers, optimizers, etc…).
Let’s try with the MNIST dataset which consists of 60k handwritten digits ranging from 0–9.
The first step is to import the libraries :
# Import libraries
!pip install autokeras
import numpy as np
import TensorFlow as tf
from tensorflow.keras.datasets import mnist
import autokeras as ak
The second step is to load your data :
# Load the data
(x_train, y_train), (x_test, y_test) = mnist.load_data()
print(x_train.shape) # (60000, 28, 28)
print(y_train.shape) # (60000,)
print(y_train[:3]) # array([7, 2, 1], dtype=uint8)
Output
Downloading data from https://storage.googleapis.com/tensorflow/tf-keras-datasets/mnist.npz 11493376/11490434 [==============================] – 0s 0us/step (60000, 28, 28) (60000,)
The third step is to initialize the image classifier, the max_trials parameter indicates the pipeline number of models used , for more complicated datasets the max_trials parameter need to be equal to 1.
# Initialize the image classifier
clf = ak.ImageClassifier(overwrite=True, max_trials=1)
# Input the training data
clf.fit(x_train, y_train, epochs=10)
# Make prediction with the best model on the test dataset
predicted_y = clf.predict(x_test)
print(predicted_y)
# Evaluate the model on the test dataset
print(clf.evaluate(x_test, y_test))
AutoKeras provides an easy way to use elements of convolutional neural networks, like convolutional layers, max-pooling, and flattening. Without the need to define the inner structure of the neural networks. Let’s make the validation step :
# With 85% training dataset and 15% validation dataset
clf.fit(x_train, y_train,validation_split=0.15,epochs=10)
Some high-level configurations can be configure using the ImageBlock argument of automodel. This option offert block type options (resnet, vp16, ..), normalization and data augmentation parameters.
# Initialize AutoKeras input and output nodes
input_node = ak.ImageInput()
output_node = ak.ImageBlock()
# Your neural network options, here we try Resnet
block_type="resnet",
# You can Normalize the dataset
normalize=True,
# You can add data augmentation
augment=False)(input_node)
# Build your output layer with the numbers of classes (in this example, 10 numbers 0-9)
output_node = ak.ClassificationHead()(output_node)
# Compile the input and output layers
clf = ak.AutoModel(inputs=input_node, outputs=output_node, overwrite=True, max_trials=1)
# Train the model on the training dataset
clf.fit(x_train, y_train, epochs=10)
Output

You can also use tf.dataset with TPU to get faster results:
# Build your tensors from the train and test datasets
train_set = tf.data.Dataset.from_tensor_slices(((x_train,), (y_train,)))
test_set = tf.data.Dataset.from_tensor_slices(((x_test,), (y_test,)))
# Create your autokeras image classifier
clf = ak.ImageClassifier(overwrite=True, max_trials=1)
# Train the model on the training dataset
clf.fit(train_set, epochs=1)
# Predict with the model with the test dataset
predicted_y = clf.predict(test_set)
# Evaluate the model with the test dataset
print(clf.evaluate(test_set))

The classification accuracy on the test dataset is 97.5%.
2. Azure studio
This free tool (without the need to register with a credit card) by Microsoft can be a modular approach that create features in an easy and fast manner automatically using personalize data engineer pipeline with complete data import options. Let’s try with the same example, the MNIST dataset which consists of handwritten digits ranging from 0–9.
The first step is to upload and create the Mnsit train and test datasets modules:

The second step is to choose the multiclass neural network :

This neural network can be fully tuned easily using the specified range for each parameter :

For more details about Azure neural network, parameters Click here. The neural network module can be used with your own customize Python or R scripts :

The next step, the neural network is train with the train and validation datasets automatically split from the training dataset :

Finally, the model is score using the classification accuracy and evaluate using the test dataset as shown below :

The classification accuracy on the test dataset is 98.8%.

For more details about Azure studio (classic version) deep learning abilities Click here.
This brief overview is a reminder of the importance of using autoML tools for choosing the right neural network architecture for images classifications. This post has the scope to covered fast and simple autoML tools for images classification as well as share useful documentation.
Sum Up
Refer to this link for a complete 8 autoML tools review with step by step python codes :
I hope you enjoy it, keep exploring!
