Coder Social home page Coder Social logo

ann's Introduction

Ann

Machine Learning library for .NET Core.

Demo

Installation

PM> Install-Package Ann

Basic Usage

Configure a Network by defining the structure and meta-parametres

var network = new Network(LossFunctionType.CrossEntropy, new Flat(0.001), 5);

Creates a neural network object with a Cross-Entropy loss function, flat learning rate 0.001 and 5 output classes

Add layers to network configuration:

network.AddInputLayer(128, 1); 
network.AddConvolutionLayer(16, 5);
network.AddActivationLayer(ActivatorType.Relu); 
network.AddPoolingLayer(2); 
network.AddFlattenLayer();
network.AddDenseLayer(256, true);
network.AddSoftMaxLayer();

AddInputLayer(128, 1) input layer, which expect input with dimensions 128x128x1

AddConvolutionLayer(16, 5) convolution layer with 16 filters of size 5x5xD, where D is the depth of the output from a previous layer

AddActivationLayer(ActivatorType.Relu) activation layer with ReLU activation function

AddPoolingLayer(2) pooling layer with a vertical and horizontal stride 2

AddFlattenLayer() flattens the result

AddDenseLayer(256, true) fully connected layer with biases

AddSoftMaxLayer() SoftMax activation

Train Model

model.TrainModel(input, target);

First argument of the TrainModel() method accepts System.Array. The dimensions of the array must match with a input layer configuration. Second argument accepts bool[]. The length of the array must match number of classes provided to Network constructor.

Weights and biases will be adjasted using Stochastic Gradient Descent with backpropagation.

Save Model

After you are done with trainig you can save the model in JSON file for a later use:

var model = network.BuildModel();
model.Save("model.json");

Use Model

var model = new Model("model.json");
double[] prediction = model.Predict(input);

TrainModel() method accepts System.Array, the dimensions of the array must match with a input layer configuration.

Examples

There are two sample projects:

  1. Ann.Mnist
  2. Ann.Fingers

Authors

Pavel koryakin [email protected]

License

This project is licensed under the MIT License - see the LICENSE.md for details.

Acknowledgments

ann's People

Contributors

koryakinp avatar

Watchers

James Cloos 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.