An Open Convolutional Neural Network Framework in C++ From Scratch
I am trying to port to Bazel and adding more documentation. It may break some of the existing functionalities; but it should be stable in three weeks.
OpenCNN is a convolutional neural network framework implemented with C++11 from scratch.
sudo apt-get install libprotobuf-dev protobuf-compiler libgflags-dev libgoogle-glog-dev
brew install gflags glog protobuf
git clone https://github.com/csukuangfj/OpenCNN.git
cd OpenCNN
mkdir build
cd build
cmake ..
make
cd OpenCNN/build
./gtest
It should pass all the test cases on your system.
We use the following network architecture for MNIST:
Layers | Description |
---|---|
Input | dim: 1x28x28 |
Convolution-1 | num_output: 32, kernel_size: 3x3 |
Batch normalization-1 | |
ReLU-1 | |
Convolution-2 | num_output: 32, kernel_size: 3x3 |
Batch normalization-2 | |
ReLU-2 | |
Max pooling-1 | win_size: 2x2, stride: 2x2 |
Convolution-3 | num_output:64, kernel_size: 3x3 |
Batch normalization-3 | |
ReLU-3 | |
Convolution-4 | num_output: 64, kernel_size: 3x3 |
Batch normalization-4 | |
ReLU-4 | |
Max pooling-2 | win_size: 2x2, stride: 2x2 |
Full connected-1 | num_output: 512 |
Batch normalization-5 | |
ReLU-5 | |
Dropout-1 | keep_prob: 0.8 |
Full connected-2 | num_output: 10 |
Softmax with log loss |
During the training a batch size of 16 is used and the accuracy reaches 95.21% after 5000 iterations. The results for training loss and test accuracy are plotted in the following figure:
A pretrained model taken after 20000 iterations achieving an accuracy of 96.74% is provided in OpenCNN-Models.
Please refer to examples/mnist for how to use OpenCNN.
More tutorials will be provided later.