/* CONSTRUCTOR */ public NetworkTraining(Network trainNetwork, string file, double learnCoef, Dictionary<int, List<int>> trainingData, List<int> expectedValues) { DigitNetwork = trainNetwork; FileName = file; LearningCoef = learnCoef; TrainingData = trainingData; ExpectedResults = expectedValues; ReadTrainingData(); if (ExpectedResults != null) NumerOfExamples = ExpectedResults.Count; else { NumerOfExamples = 0; Console.WriteLine("No training examples read!!!"); } CountCorrect = 0; CountIncorrect = 0; }
public App(int numOfLayers = 2, int numOfNeuronsInLayer = 10, double learnCoef = 1, int numberOfEpochs = 10) { DigitNetwork = new Network(64, numOfLayers, numOfNeuronsInLayer); LearningCoef = learnCoef; string fileTrain = "NeuronApp\\optdigits.tra"; string fileTest = "NeuronApp\\optdigits.tes"; TrainingData = new Dictionary<int, List<int>>(); TestingData = new Dictionary<int, List<int>>(); ExpectedTrainingResults = new List<int>(); ExpectedTestingResults = new List<int>(); Training = new NetworkTraining(DigitNetwork, fileTrain, LearningCoef, TrainingData, ExpectedTrainingResults); Training.TrainNetwork(numberOfEpochs); Console.WriteLine("Correct = {0}, Incorrect = {1}", Training.CountCorrect, Training.CountIncorrect); Console.WriteLine("Percent correct = {0}", 100 * ((double)Training.CountCorrect) / (Training.CountCorrect + Training.CountIncorrect)); Testing = new NetworkTesting(DigitNetwork, fileTest, LearningCoef, TestingData, ExpectedTestingResults); Testing.TestNetwork(); Console.WriteLine("Correct = {0}, Incorrect = {1}", Testing.CountCorrect, Testing.CountIncorrect); Console.WriteLine("Percent correct = {0}", 100 * ((double)Testing.CountCorrect) / (Testing.CountCorrect + Testing.CountIncorrect)); }