public void PerformFinalTest(List <List <Face> > faces) { var stopwatch = new Stopwatch(); stopwatch.Start(); var date = DateTime.Now.ToString("yyyy-dd-M-HH-mm-ss"); var networkLearningInput = NetworkHelper.CreateNetworkInputDataSet(faces, 12, 5, DataSetType.Learning, 12); var networkLearningOutput = NetworkHelper.CreateNetworkOutputDataSet(faces, 12, 5, DataSetType.Learning, 15); var networkValidationInput = NetworkHelper.CreateNetworkInputDataSet(faces, 12, 5, DataSetType.Validation, 12); var networkValidationOutput = NetworkHelper.CreateNetworkOutputDataSet(faces, 12, 5, DataSetType.Validation, 15); var networkTestingInput = NetworkHelper.CreateNetworkInputDataSet(faces, 12, 5, DataSetType.Testing, 12); var networkTestingOutput = NetworkHelper.CreateNetworkOutputDataSet(faces, 12, 5, DataSetType.Testing, 15); var learningSet = NetworkHelper.NormaliseDataSet(networkLearningInput, networkLearningOutput); var validationSet = NetworkHelper.NormaliseDataSet(networkValidationInput, networkValidationOutput); var testingSet = NetworkHelper.NormaliseDataSet(networkTestingInput, networkTestingOutput); foreach (double learningRate in new double[] { 0.001, 0.003 }) { Parallel.ForEach(seeds, (x) => { var inputDataCopy = new InputClass(learningRate, id.Momentum, id.HiddenLayers, id.HiddenNeurons, id.Bias, id.PeopleCount, id.ActivationFunction, id.IterationsCount); NetworkHelper.LearnNetwork(learningSet, testingSet, faces[0][0].features.Count, 15, inputDataCopy, validationSet, x); Task.Factory.StartNew(() => XmlFileWriter.WriteDataToFile("FinalTest" + date + ".xml", inputDataCopy.LearningError, inputDataCopy.ValidationError, inputDataCopy.TestingError, inputDataCopy.ElapsedTime, inputDataCopy.IterationsCount, inputDataCopy.LearningFactor, inputDataCopy.Momentum, inputDataCopy.HiddenLayers, inputDataCopy.HiddenNeurons, inputDataCopy.Bias, stopwatch.Elapsed, null, x) ); }); } }
private void MainCalculationLoop(double[] _learningRate, double _momentum, int[] _hiddenLayersCount, bool[] _bias, int[] _neuronsCount, INeuralDataSet learningSet, INeuralDataSet validationSet, INeuralDataSet testingSet, List <List <Face> > faces, string date, TimeSpan timeFromStart) { foreach (var learningRate in _learningRate) { foreach (var neuronsCount in _neuronsCount) { foreach (var hiddenLayersCount in _hiddenLayersCount) { foreach (var bias in _bias) { var inputData = new InputClass(learningRate, _momentum, hiddenLayersCount, neuronsCount, bias, 15, new ActivationSigmoid(), 40000); NetworkHelper.LearnNetwork(learningSet, testingSet, faces[0][0].features.Count, 15, inputData, validationSet); Task.Factory.StartNew(() => XmlFileWriter.WriteDataToFile("GridSearch" + date + ".xml", inputData.LearningError, inputData.ValidationError, inputData.TestingError, inputData.ElapsedTime, inputData.IterationsCount, learningRate, _momentum, hiddenLayersCount, neuronsCount, bias, timeFromStart) ); } } } } }
public void PerformCalculation(InputClass inputData, List <List <Face> > faces, string calcStartDate, TimeSpan timeFromStart, bool[] activeFeatures = null) { Console.WriteLine("Szykuje dane zbioru uczacego"); var networkLearningInput = NetworkHelper.CreateNetworkInputDataSet(faces, 12, 5, DataSetType.Learning, 12, activeFeatures); var networkLearningOutput = NetworkHelper.CreateNetworkOutputDataSet(faces, 12, 5, DataSetType.Learning, 15); var networkValidationInput = NetworkHelper.CreateNetworkInputDataSet(faces, 12, 5, DataSetType.Validation, 12, activeFeatures); var networkValidationOutput = NetworkHelper.CreateNetworkOutputDataSet(faces, 12, 5, DataSetType.Validation, 15); var networkTestingInput = NetworkHelper.CreateNetworkInputDataSet(faces, 12, 5, DataSetType.Testing, 12, activeFeatures); var networkTestingOutput = NetworkHelper.CreateNetworkOutputDataSet(faces, 12, 5, DataSetType.Testing, 15); var learningSet = NetworkHelper.NormaliseDataSet(networkLearningInput, networkLearningOutput); var validationSet = NetworkHelper.NormaliseDataSet(networkValidationInput, networkValidationOutput); var testingSet = NetworkHelper.NormaliseDataSet(networkTestingInput, networkTestingOutput); NetworkHelper.LearnNetwork(learningSet, testingSet, faces[0][0].features.Count, this.PeopleCount, inputData, validationSet); Task.Factory.StartNew(() => XmlFileWriter.WriteDataToFile("Genetic" + calcStartDate + ".xml", inputData.LearningError, inputData.ValidationError, inputData.TestingError, inputData.ElapsedTime, inputData.IterationsCount, inputData.LearningFactor, inputData.Momentum, inputData.HiddenLayers, inputData.HiddenNeurons, inputData.Bias, timeFromStart, activeFeatures) ); }