Skip to content

IltonPfleger/NeuroPulse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NeuroPulse

C LICENSE ML PULSE

About The Project

The aim of this project is to create a user-friendly Neural Networks library for the C programming language. The library should be easy for users to understand and modify. The core concept is to make everything modular, enabling users to adapt architectures to solve their problems.

Features

  • Stochastic Gradient Descent.
  • Batch Gradient Descent.
  • Mini-Batch Gradient Descent.
  • Custom Activation Functions Layer.
  • Convolutional Layers.
  • RNN Features.
  • Optimizers like RMSProp, Adam, etc.
  • Custom Loss Functions.

Example

#include <activations/relu.h>
#include <activations/sigmoid.h>
#include <layers/dense.h>
#include <losses/mse.h>
#include <pulse.h>
#include <stdio.h>

int main()
{
    constexpr int SAMPLES          = 4;
    constexpr int INPUT_DIMENSION  = 2;
    constexpr int OUTPUT_DIMENSION = 1;

    auto constexpr DTYPE = PULSE_DOUBLE;
    auto const ReLU      = PULSE_RELU[DTYPE];
    auto const Sigmoid   = PULSE_SIGMOID[DTYPE];
    auto const MSE       = PULSE_MSE[DTYPE];

    const double x[SAMPLES][INPUT_DIMENSION]  = {{0, 1}, {1, 1}, {1, 0}, {0, 0}};
    const double y[SAMPLES][OUTPUT_DIMENSION] = {{1}, {0}, {1}, {0}};
    const void* const X[SAMPLES]              = {x[0], x[1], x[2], x[3]};
    const void* const Y[SAMPLES]              = {y[0], y[1], y[2], y[3]};

    struct pulse_layer_s* model = pulse_create_model(2, pulse_dense_layer(INPUT_DIMENSION, 4, DTYPE, ReLU), pulse_dense_layer(4, OUTPUT_DIMENSION, DTYPE, Sigmoid));

    pulse_train(model, (pulse_train_args_t){.samples = SAMPLES, .epoch = 10000, .batch_size = 1, .lr = 0.1}, MSE, X, Y);

    printf("TRAIN RESULT\n");
    for (int i = 0; i < 4; i++)
        printf("Entrada: %d %d, Output: %f\n", (int)x[i][0], (int)x[i][1], *(double*)pulse_forward(model, x[i]));

    pulse_free(model);
}

Notes:

  • The project requires C standard libraries. If using non-compiled files, include them in your compilation.

  • Feel free to send ideas, suggestions, questions, and requests.

About

A small and modular Neural Networks library for C programs

Topics

Resources

License

Stars

8 stars

Watchers

1 watching

Forks

Packages

 
 
 

Contributors