Machine Learning
Rock, Paper, Scissors

View on Github

Convolutional Neural Network (CNN)

In this project, I use Convolutional Neural Network (CNN) to do Image Classification. CNNs is a deep learning algorithm that is emerged from the study of the brain’s visual cortex, and they have been used in image recognition since the 1980s. CNNs have managed to achieve superhuman performance on some complex visual tasks.


CNN Architecture

1. Convolutional Layer : In this layer, neurons in the first convolutional layer are not connected to every single pixel in the input image, but only to pixels in their receptive fields. Then, each neuron in the second convolutional layer is connected only to neurons located within a small rectangle in the first layer. In this layer, their allows the network to concentrate on small low-level features in the first hidden layer and assemble them into larger higher-level features in the next hidden layer.


2. Polling Layer : In this layer, the goal is to subsample the input image in order to reduce the computational load, the memory usage, and the number of parameters.


3. Full Connected Layer : This layer is composed of 2 hidden dense layers and a dense output layer.


Dataset

The dataset that I used are from Kaggle . This dataset contains images of hand gestures from the Rock-Paper-Scissors game.


Library


First, import the required libraries:

1. numpy : for array-based computation.

2. matplotlib : for visualization and plotting purposes.

3. tensorflow and keras : to perform data preprocessing and to define CNN architecture.

4. ImageDataGenerator : will be used in data augmentation process.


Data Preprocessing


Sequential Model


Model Compilling


Callbacks


Train the Model


Predicting Image


Result



References

Geron, A. (2019). Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow (2nd ed.). O'Reilly Media.