CNN Classifying Handwritten Digits
-
Intro
-
Predicting handwritten numbers
-
Conclusion
Information
Primary software used | Owl |
Course | CNN Classifying Handwritten Digits |
Primary subject | AI & ML |
Secondary subject | Machine Learning |
Level | Intermediate |
Last updated | November 11, 2024 |
Keywords |
Responsible
Teacher | |
Faculty |
CNN Classifying Handwritten Digits 0/2
CNN Classifying Handwritten Digits link copied
CNN are commonly used for image classification and have proven effective in many other applications, such as object detection and image segmentation.
A Convolutional Neural Network (CNN) is a neural network that processes and analyzes visual data. The critical difference between a CNN and a Dense Neural Network (DNN) is that CNNs process visual data by applying convolutions and pooling operations to the input data, which allows them to learn spatial hierarchies of features from the input. On the other hand, DNNs are fully connected networks that perform the exact computations for all input data, regardless of the input’s spatial structure. In the example of classifying hand-written numbers, a CNN may outperform a DNN due to its ability to identify and extract features from the spatial structure of the images.
CNN Classifying Handwritten Digits 1/2
Predicting handwritten numbers link copied
Data generation
We import handwritten images from the MNIST dataset, then reshape the images into a tensor with dimensions 28x28x1 (height, width, number of color channels). The number of color channels represents the depth of the image, typically either 1 for grayscale or 3 for RGB.
Training
We will use Pug to build two network architectures: a Convolutional Neural Network (CNN), and a fully connected network. The main difference between these two is their architecture, where the CNN has a specific structure for image classification tasks.
The labeled images from the MNIST data set are then fed into either a CNN or a fully connected neural network architecture using the Pug SL component. The architecture is defined using the Pug Object component, which is plugged into the ANN input of the Pug SL component. Running the component trains the network to classify the images based on their labels, which are numbers zero to nine.
Testing
After connecting the trained network to the prediction component, we will use the testing dataset from the MNIST component to evaluate the accuracy of the network. The Owl component can then be used to visualize the tensor.
CNN Classifying Handwritten Digits 2/2
Conclusion link copied
You now learned how to use the plug-in Owl for a classification problem in Grasshopper. Here you can find an overview of the script.
Final exercise file
Here you find the final GH script of the tutorial.