Giter Site home page Giter Site logo

machine.academy's Introduction

machine.academy

Neural network training library written in C# (.net Core 3.1) as a learning project.

Demos:

Features:

  • GPU accelerated Backpropagation (using OpenCL)
  • Cost functions:
    • Mean-Squared
    • Cross-entropy
  • Activation functions:
    • Sigmoid
  • Optional L1 and L2 regularization
  • Xavier weight initialization
  • Stochastic gradient descent with shuffled mini-batches

Sample code:

Initializing a random network:

var layerConfig = new int[]{ 784, 32, 32, 10 };
var network = Network.CreateNetworkInitRandom( layerConfig, new SigmoidActivation() );

Initializing from JSON:

string jsonData = "{ ... }";
var network = Network.CreateNetworkFromJSON( jsonData ); 

Exporting to JSON:

string json = network.ExportToJSON();

Calculating an output to a given input:

float[] input = { ... };
ComputeDevice computeDevice = ComputeDeviceFactory.GetFirstOpenCLDevice(); //Get an OpenCL device
float[] results = network.Compute( input, computeDevice );

Training

ComputeDevice computeDevice = ComputeDeviceFactory.GetFirstOpenCLDevice(); //Get an OpenCL device
List<TrainingSuite.TrainingData> trainingData = new List<TrainingSuite.TrainingData>();

//Set up training examples
for (int i = 0; i < 10000; ++i)
{
    float[] trainingInput = ...;
    float[] desiredOutput = ...;
    trainingData.Add( new TrainingSuite.TrainingData( trainingInput, desiredOutput ) );
}

TrainingSuite trainingSuite = new TrainingSuite( trainingData );

//Set up training configuration
trainingSuite.config.epochs = 100;
trainingSuite.config.shuffleTrainingData = true;
trainingSuite.config.miniBatchSize = 50;
trainingSuite.config.learningRate = 0.005f;
trainingSuite.config.costFunction = new CrossEntropyErrorFunction();
trainingSuite.config.regularization = TrainingSuite.TrainingConfig.Regularization.L2;
trainingSuite.config.regularizationLambda = 0.5f;

var trainingPromise = network.Train( trainingSuite, computeDevice );

trainingPromise.Await();

Projects in the repo

Macademy

The neural network library

OpenCl.DotNetCore.Interop

Part of the following library: https://github.com/lecode-official/opencl-dotnet. Used for OpenCL access from .net Core

Testing

Tests for the library

TestConsole

A console command line for testing

NumberRecognizer (uses WinForms)

A sample app that can load the MNIST digit dataset and trains a network.

Sandbox (uses WinForms)

A test app for development with no specific purpose but to try our some features using a ui.

docs/WebApps/NumberRecognizer

An HTML web application that uses an already trained network to recognize a drawn number.

docs/WebApps/Evo

An HTML web application that uses neural networks and an evolutional algorithm for training racecars to learn driving on various racetracks.

Dependencies

The following dependencies are set up in nuget:

  • Newtonsoft.Json

This project also includes parts of opencl-dotnet: https://github.com/lecode-official/opencl-dotnet

Future plans:

  • Optimize memory layout (to reduce number of buffer copies)
  • New features: Dropout, Softmax layers
  • More activation functions
  • Convolutional layer
  • LSTM networks

Resources

These are some nice resources for learning about Neural Networks:

machine.academy's People

Contributors

zbendefy avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.