Skip to content

Vincouux/CUDA-Neural-Network

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CUDA NEURAL NETWORK

Simple Neural Network implementation in C++ using Cuda GPU Programming.

How it works ?

Includes

#include "Model/model.hpp"
#include "Layer/input.hpp"
#include "Layer/dense.hpp"
#include "Activation/activation.hpp"

Instantiate a new Model

Model model = Model();

Add Layers

model.add(new Input(784));
model.add(new Dense(256, TanH));
model.add(new Dense(10, Sigmoid));

Compile & Summary

model.compile();
model.summary();

Load Data & Fit

Matrix<float> X = Matrix<float>("data/x_train.csv") / 255.f;
Matrix<float> Y = Matrix<float>("data/y_train.csv");

/*
Model::fit(const Matrix<float>& X, const Matrix<float>& Y,
           unsigned epochs, float lr, bool earlystopping, bool verbose)
*/
model.fit(X, Y, 1000, 0.001f, true, true);

Predicting & Testing

Matrix<float> XT = Matrix<float>("data/x_test.csv") / 255.f;
Matrix<float> YT = Matrix<float>("data/y_test.csv");
Matrix<float> YP = model.predict(XT);
float error = 0.5f * (YT - YP).power(2).sum() / YT.getHeight();
std::cout << "Error: " << error << std::endl;

Work In Progress

About

Simple Cuda Neural Network

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •