Skip to content

dylanrainwater/NN

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Neural Network (NN)

This is my implementation of a simple neural network classification library in C++.

Documentation

It library's classifier expects data in the form of 1+ doubles, followed by a label. Some example datasets are included in the repository.

NN(string input_file);

The constructor takes in the name of a file to get data from. If no name is given, you will need to manually enter data and call populateWeights().

void populateWeights();

This function will initialize the weights of the program with random variables. The neural network needs data before it can do this.

void createLabel(double perfect, double lower_bound, double upper_bound, string& label);

createLabel allows you to define a label to the neural network. Perfect is what an optimal data point would have as a value. lower_bound is the minimal value that type of data would have, and upper_bound is the maximum.

void addData(vector <vector <double>>& data);

addData allows you to add a new set of data to the classifier before training it.

void addDataPoint(vector <double>& data_point);

addDataPoint allows you to add a single data point to the classifier before training it.

void train(int iterations=1000);

train will just train the neural network based on the data already inserted.

void reset(bool keep_weights);

reset will reset the values of your weights and bias term. If keep_weights is true, the weights will be reverted to the original weights before training. Otherwise, they will be refreshed to new values.

vector <double> predict(vector <vector <double>>& data);

Gives a vector of predictions for the given data.

double predict(vector <double>& data_point);

Gives a prediction for the given data point.

void setAlpha(double alpha);

Sets the learning rate to alpha.

About

Simple neural network based classifier in C++

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages