Tinn is a tiny and dependency free neural network implementation for dotnet. It has three configurable layers: an input layer, a hidden layer and an output layer.
Create a neural network:
var network = new TinyNeuralNetwork(inputCount: 2, hiddenCount: 4, outputCount: 1);
Load a data set:
// This is XOR operation example.
var input = new float[][]
{
new []{ 1f, 1f }, // --> 0f
new []{ 1f, 0f }, // --> 1f
new []{ 0f, 1f }, // --> 1f
new []{ 0f, 0f }, // --> 0f
};
var expected = new float[][]
{
new []{ 0f }, // <-- 1f ^ 1f
new []{ 1f }, // <-- 1f ^ 0f
new []{ 1f }, // <-- 0f ^ 1f
new []{ 0f }, // <-- 0f ^ 0f
};
Train the network until a desired accuracy is achieved:
for (int i = 0; i < input.Length; i++)
{
network.Train(input[i], expected[i], 1f);
}
// Note: you will probably have to loop this for a few times until network improves.
Try to predict some values:
var prediction = network.Predict(new [] { 1f, 1f });
// Will return probability close to 0f, since 1 ^ 1 = 0.
For more examples see the examples directory and automated tests.
The original library was written by glouw in C.