static void Main(string[] args) { // http://habrahabr.ru/post/144881/ int threshold = 10; // It is neuron threshold. Incrementing this value we make neuron more accuratem but it takes more time to learn. int neuronTarget = 5; // It is neuron's target value to recognize. He will be trained to do it well. Neuron neuron = new Neuron(threshold, neuronTarget); List<TrainingData> trainingDataCollection = new TrainingDataProvider().ProvideTrainingData(); NeuronTrainer trainer = new NeuronTrainer(neuron); // trainer will take care about training scales of neoron's synapses. for (int i = 0; i < 10; i++) { // During training step neuron will take inbound impact and trainer will correct our neuron's synapses according to its answers. // We are going intentionally skip impact with code "5.6". Having this not learned impact we will be able to check our neuron after training trainer.Train(trainingDataCollection.Where(x => x.Code != "5.6").ToList().Shuffle<TrainingData>()); } Debug.WriteLine("Neuron's synapses after complex training:"); Debug.WriteLine(neuron); // Now neuron will try to recognize new unknown impact. var isRecognized = neuron.Recognize(trainingDataCollection.Where(x => x.Code == "5.6").FirstOrDefault()); Debug.WriteLine("Is recognized unknown correct impact: " + isRecognized); // Lets check that our neuron works as expected giving to him the most complicated impact. isRecognized = neuron.Recognize(trainingDataCollection.Where(x => x.Code == "6").FirstOrDefault()); Debug.WriteLine("Is recognized known incorrect impact: " + isRecognized); }
public NeuronTrainer(Neuron neuron) { this.neuron = neuron; }