Coder Social home page Coder Social logo

a1exxd0 / hadolibrary Goto Github PK

View Code? Open in Web Editor NEW
9.0 1.0 1.0 12.36 MB

Lightweight, header only ML library with support for OpenMP for a variety of neural networks.

C++ 98.95% C 0.34% NASL 0.68% Makefile 0.01% CMake 0.02%
cpp20 machinelearning neuralnetwork

hadolibrary's Introduction

A library for implementing Neural Networks in C++

Lightweight, templated, highly vectorised (through Eigen backend), and optimised library for a variety of neural networks. Tested for Linux.

Supports models for:

  • Deep Neural Networks

Will support soon:

  • Convolutional Neural Networks
  • RNN Networks
  • LSTM Networks
  • Transformer Networks

Example usages are stored in src folder to run. See "XorModel.cpp", for example.

Usage

You'll need the Eigen library inside of your project, as well as everything in the HaDo/ subdirectory. See the Makefile for a general idea of how to compile it all. Use "-fopenmp" for compilation with multithreading enabled, if you have OpenMP installed on your system. The MakeFile provided gives an example using 'make omp' as a target.

You could have for an example file structure:

project  
|   MakeFile
|   
├───src
|   |   main.cpp
|
├───Eigen
|   ...
|
├───HaDo
|   ...
|
└───res.png

Notably, you should include the Eigen and Hado files in your include flags when compiling.

To use in your main program, simply import the desired module set available in the top level of the HaDo folder, for example:

#include <HaDo/ConvolutionalNeuralNetwork>

void TwoCategoryMNIST(){
    hado::Pipeline<double> pipeline;

    pipeline.pushLayer(
        hado::ConvolutionalLayer<double, hado::relu<double>, hado::relu_prime<double>>(1, 2, 28, 28, 3, 1, 0)
    );

    pipeline.pushLayer(
        hado::MaxPoolLayer<double>(2, 26, 26, 2, 2, 0)
    );

    ...
}

Contributions

Feel free to for the repository and set up a pull request, either to resolve an existing issue, or add a new feature. All help is appreciated here with the team of just 2 of us!

Code should pass tests before requesting to merge, and if you write fully new code, it would be awesome to see some tests made for that too!

In order to make and build for tests, run:

cd ${PROJECT_SOURCE_DIR}/
mkdir build && cd build
cmake ..
cmake  --build .
ctest -V -C -T memcheck
# or just ctest -V -C if you want a quick check

This is more of a learning project for new C++ers, so there's no real strict requirements here. Feel free to reach out to either myself or other contributros for help on this.

Happy coding!

TODO

  • Image -> Bitmap formatting ??? Maybe use PPM for raw RGB
  • Dense Layers
  • Activation Layers (tanh, sigmoid, ReLU, softmax so far)
  • Mean Squared Error implementation
  • Cross-Entropy Loss implementation
  • Method to pass through and verify layer setup
  • Pipeline class
  • Convolutional Layers
  • Pooling Layers
  • Saving a model (JSON or binary?)
  • Getting it running on a GPU
  • Getting it running on a cluster

hadolibrary's People

Contributors

a1exxd0 avatar haaris-farooq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

haaris-farooq

hadolibrary's Issues

Add test integration with GoogleTest or otherwise

Is your feature request related to a problem? Please describe.
Right now, the library lacks a thorough testing framework. It is causing an issue in the convolutional layer where we can't/it is hard to pinpoint any sort of error.

Describe the solution you'd like

  • Integrate a testing framework
  • Possibly refactor build system to cmake
  • Document how this is done

Describe alternatives you've considered

  • Could possibly use the Catch framework instead. Whatever the fixer is more familiar with.

Add MPI integration

Is your feature request related to a problem? Please describe.
Where's that cool distributed system support?

Describe the solution you'd like

  • Refactor where required and add multi-node support for system

Additional context

  • Will look to code again for GPU support later on with cublas libraries, but this could involve rewriting the whole codebase as it currently uses Eigen.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.