MNIST Convolutional neural network

Medium
1 hours
January 12, 2023
Youssef MENJOUR

This example aim to explain how to design, train and integrate in LabVIEW environment a 2D CNN model using MNIST dataset.

Front panel overview

In this section we will present the front panel.

The user interface is composed of 4 tab (train, test, incorrectly classified data and confusion matrix). To run the example we just have to action the “load data” button. The example will load dataset and start the training.

During the training, you can test the model for prediction and see the evolution of it as he is updated with latest training weight.

Train tab

Train tab display all informations needed to follow the training proces.

 

Incorrectly classified image tab

This tab display to the user the incorrectly classied test set images by the model during the training. By the time the model will gain more accuraty and less and less images will be incorrectly classified.

 

Test tab

Test tab able user to test the model by drawing a number and see the prediction model.

Confusion matrix tab

This tab shows the user the model’s confusion matrix to help understand the strengths and weaknesses of the model.

Diagram global overview

This section show how the model and HAIBAL functionalities are integrated inside a LabVIEW architecture design.

The architecture is a queue message handler simplified. It’s composed of 4 parallels loops. 1 is managing user event (producer) and 3 managing different processes (consumer). One thread is for the design and training model, one thread for test and prediction and one is a specific thread according MNIST dataset managing drawing image interface.

Model design

Data are images of 28 X 28 pixels. As we will design convolutional network we only use 1 channel (black and white).

The model is a convolutional neural network composed of one input layer (1,28,28) followed by one Convolutional, MaxPool, Convolutionnal, MaxPool, Flatten then 2 Denses layers.

The latest activation is softmax with an outputs of 10 for the classification.

We use a crossentropy loss for this example.

Model train

The model train process is “classic”, we repeat a sequence of Forward – Loss – Backward to process to the train of the model.

Model testΒ 

As all loop run in parallels, the prediction loop combined with the draw loop (user drawing interface managed by this process) make possible to test the model during the training.

Testing model consist to forward and display data forwarded process from updatetd model with data draw by the user.

How to acces to this example ?

The MNIST DNN example is available in the LabVIEW find example session. Use the Keyword DNN and launch it.

The LabVIEWΒ  convolutional neural network using MNIST dataset is now available with the HAIBAL deep learning toolkit.

Need help from the community

Join the GRAIPHIC community as part of a vibrant Ecosystem. This is your place to
network, ask questions, and collaborate on code with users all over the world.

Need access to the official instruction manual ?

Visit the HAIBAL knowledge base as the documentation from which you can
start from scratch and learn the advanced features