Building Image classification Model

In this tutorial shows we use AlexNet, a Convolutional Neural Network used for image classification purposes training on Dogs Breed Data.

Adding data

Before starting with creating the model, add training data as buckets in your dashboard. You can refer to the section ‘Data format’ section in ‘Creation bucket’.

Data can be provided in form of directories where each directory contains images from a single class and directory name corresponds to class name. Alternatively, images can be provided in a single directory and a separate json file containing image to class mapping.

For example: In this case, we are using 120 class dogs data to build model. In the training data, we’ve create directories with class name as folder name and images of that class in that folder. We’ve stored it in S3 in AWS.

example

Example

Creating the Neural Network

To create the neural network, go to Vega > Networks and click on ‘Add New’. Define the Network profile parameters (Refer to “Creating Neural Network” section).

Data Layer Convolution Layer 1 Convolution Layer 2
Name Data_lyr_1
Type image
Width 224
(you can define your own specifications of input image into network)
Height 224
Image Type Color
Zero Center Yes
Normalization Yes
Number of Filters 96
Kernel Size X 11
Kernel Size Y 11
Stride X 4
Stride Y 4
Pad SAME
Activation Relu
Name CNN_lyr_1
Number of Filters 256
Kernel Size X 5
Kernel Size Y 5
Stride X 1
Stride Y 1
Pad SAME
Activation Relu
Name CNN_lyr_2
Convolution Layer 3 Convolution Layer 4 Convolution Layer 5
Number of Filters 384
Kernel Size X 3
Kernel Size Y 3
Stride X 1
Stride Y 1
Pad VALID
Activation Relu
Name CNN_lyr_3
Number of Filters 384
Kernel Size X 3
Kernel Size Y 3
Stride X 1
Stride Y 1
Pad VALID
Activation Relu
Name CNN_lyr_4
Number of Filters 256
Kernel Size X 3
Kernel Size Y 3
Stride X 1
Stride Y 1
Pad VALID
Activation Relu
Name CNN_lyr_5
MaxPooling2D Layer 1 MaxPooling2D Layer 2 MaxPooling2D Layer 3
Kernel Size X 3
Kernel Size Y 3
Stride X 2
Stride Y 2
Pad VALID
Name Pool_lyr_1
Kernel Size X 3
Kernel Size Y 3
Stride X 2
Stride Y 2
Pad VALID
Name Pool_lyr_2
Kernel Size X 3
Kernel Size Y 3
Stride X 2
Stride Y 2
Pad VALID
Name Pool_lyr_3
Dense Layer 1 Dense Layer 2 Dense Layer 3
Number of Filters 4096
Activation Relu
Name Dense_lyr_1
Number of Filters 4096
Activation Relu
Name Dense_lyr_2
Number of Filters 120
Activation Softmax
Name Dense_lyr_3
Dropout Layer 1 Dropout Layer 2 Flatten Layer
Keep_prob 0.5
Name Dropout_lyr_1
Keep_prob 0.5
Name Dropout_lyr_2
Name Flatten_lyr
Loss Layer Output Layer
Loss_function Categorical
Optimizer SGD
Name Loss_lyr
No Parameters
Alexnet Network

Alexnet Network

Training the Network

Initiation of training

Once the network is created, you can click on ‘Create Model’ to initiate the training. It’ll prompt for the model profile specifications. You can either use ‘Free’ Resources or launch the server of your choice. If the training data is larger in size, choose the bigger servers as it will have more memory to process the model. And define the Network parameters as per the reference:

Tracking the training

Once the server is initiated, you can track the performance of the model at each epoch at the ‘Model page’. If you want to make changes to the models, you can end the training, make changes and re-initiate the training again.

End of training

Once the model is trained, you can see how the performance is varying at each epoch.

Training Graph

Training Graph

To terminate the server, click on ‘Stop Server’ which will terminate the training and stops all the processes. The trained weights will still be available for the trained epochs. You can create the inferencing system at any time you wish to.

If you choose to create an inferencing system, it can be initiated through ‘Create API’ button, Vega can scale the API automatically in the desired server.