For the Machine Learning course, we developed a library to build and train feedforward neural networks in C++ exploiting Armadillo numerical library. The main implemented techniques are gradient descent with backpropagation, k-fold cross-validation and grid-search (parallel and sequential). Multiple activation functions are available (sigmoid, tanh, relu and linear). We tested our library on Monks datasets and on a specific dataset given by the professor. All the tests were made with different models using one to five hidden layers. More information about the project and the algorithms we implemented can be found in the report.
The project use Cmake 3.16 as building system and it can be downloaded here.
The package manager used is Conan. You can install it with the following commands:
pip install conan
Running the following command to solve this issue:
source ~/.profile
- Clone the following repo: https://github.com/darcamo/conan-armadillo;
- Inside the cloned repo run:
conan create . armadillo/stable
- If Armadillo is installed correctly an example program is execute and you can start use it through Conan.
If CMake and Armadillo were installed correctly you have to create a directory where cmake store the configuration files needed to run the project:
mkdir build && cd build
Inside the build folder to generate the files that are needed by Conan type:
conan install ..
Then the for the CMake files give:
cmake ..
In the end to build the project type:
cmake --build .
If all the process is done correctly a /bin folder is created with a binary file inside. This file can be executed with:
./MLProject
The error of the training set and validation set is print during the execution.
Here we show a learning curve plot we obtained during the training phase.
- Serialization of NN: https://www.boost.org/doc/libs/1_72_0/libs/serialization
- Plot with matplotlibcpp: https://github.com/lava/matplotlib-cpp
- Giovanni Sorice 💻 - Giovanni Sorice
- Francesco Corti 🤓 💻 - FraCorti