A tiny framework of convolutional neural networks with C++ implementation. You can add arbitrary number of convolutional layers, max pooling layers and hidden layers to construct your own convolutional neural networks.
This framework contains a sub neural network framework which is multi-layer neural network, you can also use it as CNNs to construct your own multi-layer neural netowrk.
This project also implemented Momentum SGD and Adam Optimizer in Multi-layer Neural Networks part and can be enabled by functions.
mkdir build && cd build
cmake ..
makeon macOS ORopen solutionif you are using windows
Tested on Windows or macOS, but should also work on linux systems.
This tiny frame work has been tested on MNIST(handwritten digits) dataset by LeCun.
- make sure there are 4 files named
train-images.idx3-ubytetrain-labels.idx1-ubytet10k-images.idx3-ubytet10k-labels.idx1-ubytein thedata/mnistpath. Dataset can be downloaded from here. - after build, if you are on macOS, run
./cppcnninbuildfolder, then it will load MNIST dataset and after 1-3 hours on CPU, it will give the test results.
Get 95% accuracy by 5 epoch, with hyperparameters:
- learning rate: 1.0
- hidden layers: one hidden layer with 256 units
- mini batch size: 256
- momentum SGD: disabled
- adam optimizer: disabled
Get 98% accuracy by 3 epoch, with hyperparameters:
- learning rate: 0.005
- convolution layers: one convolution layer with
8 convolution filters,size 3,stride 1,no padding - pooling layers: one max pooling layer with
size 2,stride 2 - hidden layers: two hidden layer with 32 and 16 units
- mini batch size: 1
- momentum SGD: disabled
- adam optimizer: disabled
- Fix pooling layer bug for odd case.
- Implement
Momentum SGDandAdam Optimizerin CNN class. - Provide average pooling layer.
- Provide GPU acceleration.