Giter Site home page Giter Site logo

neuralnetwork's Introduction

NeuralNetwork

A .Net implementation of an artificial neural network

An example of evolving this neural network using a genetic algorithm can be found at GeneticAlgorithm and a full example using the neural network and genetic algorithm to evolve it's topology for a specific task can be found at BasicGameNeuralNetworkTrainer

Creating a Neural Network

Creating an instance of NeuralNetwork can be done using an instance of NeuralNetworkFactory which implements INeuralNetworkFactory.

The Short Way

The short way to create one is to use the default values as follows:

var numInputs = 3;
var numOutputs = 1;
var numHiddenLayers = 1;
var numNeuronsInHiddenLayer = 5;
INeuralNetwork network = NeuralNetworkFactory.GetInstance().Create(numInputs, numOutputs, numHiddenLayers, numNeuronsInHiddenLayer);

This will create an instance of INeuralNetwork which has 3 inputs, 1 output, and 1 hidden layer containing 5 neurons.

The Long Way

If you wish to override some of the inner functionality, you can do so by extending the dependent interface factories and injecting them. Below are the default values that are set the same as if you used the short way, just explicitly injected:

var somaFactory = SomaFactory.GetInstance(new SimpleSummation());
var axonFactory = AxonFactory.GetInstance(new TanhActivationFunction());
var randomInit = new RandomWeightInitializer(new Random());
var hiddenSynapseFactory = SynapseFactory.GetInstance(randomInit);
var ioSynapseFactory = SynapseFactory.GetInstance(new ConstantWeightInitializer(1.0));
var biasInitializer = randomInit;
INeuralNetworkFactory factory = NeuralNetworkFactory.GetInstance(somaFactory, axonFactory, hiddenSynapseFactory, ioSynapseFactory, biasInitializer);

var numInputs = 3;
var numOutputs = 1;
var numHiddenLayers = 1;
var numNeuronsInHiddenLayer = 5;
INeuralNetwork network = factory.Create(numInputs, numOutputs, numHiddenLayers, numNeuronsInHiddenLayer);

Using the Network

Using the network requires setting the inputs, calling Process() on the network, and the getting the outputs of the network:

var inputs = new double[] { 1.4, 2.04045, 4.2049558 };
network.SetInputs(inputs);
network.Process();
var outputs = newtwork.GetOutputs();

Configuring the Topology

When evolving the network, you can get and set the topology of the network

NeuralNetworkGene genes = network.GetGenes();
...
modify gene code
...
INeuralNetwork newNetwork = factory.Create(genes);

neuralnetwork's People

Contributors

jobeland 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.