Skip to content
Simple neural network implemented in C# for Unity3D
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Assets Fixing whitespace Dec 31, 2017
ProjectSettings Fixed typo in neural net constructor Sep 29, 2016
.gitignore Added another test scene. Issue: Reloading feature does not reset the… Sep 12, 2017
README.md Update README.md Feb 19, 2018

README.md

Unity3D Neural Network

This is a C# implementation of a simple feedforward neural network.

This neural network can be used to solve any problems where an input vector of values from 0-1 results in an output vector of values from 0-1.
To use a neural network you must create a Network and a Dataset

private static NeuralNetwork.Network net;
private static List<DataSet> dataSets; 

//Initialize Network and Dataset
void Awake()
{
    int numInputs, numHiddenLayers, numOutputs;
    net = new NeuralNetwork.Network(numInputs, numHiddenLayers, numOutputs);
    dataSets = new List<DataSet>();
}

You can add data points to the dataset using

dataSets.Add(new DataSet(double[] inputs, double[] desiredOutputs));

Train the network with by calling

net.Train(dataSets, MinimumError);

MinimumError is the mimimum desired error for the network (The network will run the same dataset multiple times if it does not have enough datapoints to hit the minimum error with one trial).

Finally, you can test an input

double[] testInput = {0, 1, 0.2, 0.13};
double[] results = net.Compute(testInput);



Sample Scenes

Color picking

This project has a demo scene showing the power of the network by using it to determine which color text is easiest to read on randomly colored backgrounds.
Alt text

Users can select the color easiest to read, and after a few trials ( > 10 ) the Neural Network will show its pick for 'easiest to read color' for the given background.

Jump

Here's another demo scene. Train the network by jumping from platform to platform (Use space). After some collected datasets the network will decide if the player has to jump or not. Image

You can’t perform that action at this time.