View on GitHub

Cifar-10

CIFAR-10 Image Classification with numpy only

by Valentyn Sichkar     Academia.edu     YouTube

CIFAR-10 Image Classification with numpy only

Example on Image Classification with the help of CIFAR-10 dataset and Convolutional Neural Network.
DOI

Test online here

Content

Short description of the content. Full codes you can find inside the course by link above:


CIFAR-10 Image Classification with numpy only

In this example we’ll test CNN for Image Classification with the help of CIFAR-10 dataset.
Following standard and most common parameters can be used and tested:

Parameter Description
Weights Initialization HE Normal
Weights Update Policy Vanilla SGD, Momentum SGD, RMSProp, Adam
Activation Functions ReLU, Sigmoid
Regularization L2, Dropout
Pooling Max, Average
Loss Functions Softmax, SVM


Contractions:


For current example following architecture will be used:
Input –> Conv –> ReLU –> Pool –> Affine –> ReLU –> Affine –> Softmax


For current example following parameters will be used:

Parameter Description
Weights Initialization HE Normal
Weights Update Policy Vanilla SGD
Activation Functions ReLU
Regularization L2
Pooling Max
Loss Functions Softmax


Loading batches of CIFAR-10 dataset

First step is to prepare data from CIFAR-10 dataset.


Plotting examples of images from CIFAR-10 dataset

After all batches were load and concatenated all together it is possible to show examples of training images.

Result can be seen on the image below.

CIFAR-10_examples


Preprocessing loaded CIFAR-10 dataset

Next, creating function for preprocessing CIFAR-10 datasets for further use in classifier.

As a result there will be following:


Saving and Loading serialized models

Saving loaded, prepared and preprocessed CIFAR-10 datasets into pickle file.


Functions for dealing with CNN layers

Creating functions for CNN layers:


Creating Classifier - model of CNN

Creating model of CNN Classifier:


Defining Functions for Optimization

Using different types of optimization rules to update parameters of the Model.

Vanilla SGD updating method

Rule for updating parameters is as following:

Vanilla SGD


Creating Solver Class

Creating Solver class for training classification models and for predicting:


Overfitting Small Data

Overfitting Small Data


Training Results

Training process of Model #1 with 50 000 iterations is shown on the figure below:

Training Model 1

Initialized Filters and Trained Filters for ConvNet Layer is shown on the figure below:

Filters Cifar10

Training process for Filters of ConvNet Layer is shown on the figure below:

Training Filters Cifar10


MIT License

github.com/sichkar-valentyn

Reference to:

Valentyn N Sichkar. Neural Networks for computer vision in autonomous vehicles and robotics // GitHub platform. DOI: 10.5281/zenodo.1317904