This project implements a Convolutional Neural Network (CNN) from scratch in C++ for MNIST and CIFAR10 data classification using OpenBLAS and OpenMP.
Be sure OpenBLAS is installed in OpenBLAS_DIR directory in CMakeLists.txt
At project root directory:
# Create build directory
mkdir -p out/build
# Move to build directory
cd out/build
# Generate build files
cmake ../..
# Build the project
cmake --build .After building, while in the out/build directory:
./CppCNN/mnist_train
./CppCNN/cifar10_train./CppCNN/mnist_inference.
├── CMakeLists.txt
├── CMakePresets.json
├── CppCNN/
│ ├── CMakeLists.txt
│ ├── data/ # MNIST dataset and model files
│ ├── include/ # Header files
│ └── src/ # Source files
├── LICENSE
└── README.md
- C++20 compatible compiler
- CMake 3.0 or higher
The project expects MNIST and CIFAR10 dataset in the CppCNN/data/mnist and CppCNN/data/cifar10 directory:
In mnist directory:
- train-images.idx3-ubyte
- train-labels.idx1-ubyte
- test-images.idx3-ubyte
- test-labels.idx1-ubyte
In cifar10 directory:
- data_batch_
N.bin - test_batch.bin
- batches.meta.txt
After training, model files will be saved in the same directory with names like mnist_model_epoch_N.bin where N is the epoch number.