Example #1
0
        public async Task PerformTests()
        {
            await Task.Run(() =>
            {
                Console.WriteLine("Szykuje dane zbioru uczacego");
                double[][] neuralLearningInput  = NetworkHelper.CreateLearningInputDataSet(learningFaces);
                double[][] neuralLearningOutput = NetworkHelper.CreateLearningOutputDataSet(learningFaces, 4);
                double[][] neuralTestingInput   = NetworkHelper.CreateLearningInputDataSet(testingFaces);
                double[][] neuralTestingOutput  = NetworkHelper.CreateLearningOutputDataSet(testingFaces, 4);
                INeuralDataSet learningSet, testingSet;

                learningSet = NetworkHelper.NormaliseDataSet(neuralLearningInput, neuralLearningOutput);
                testingSet  = NetworkHelper.NormaliseDataSet(neuralTestingInput, neuralTestingOutput);

                TestsHelper.RunTests(learningSet, testingSet, learningFaces[0].Features.Count, testingFaces.Count, learningFaces, testingFaces);
            });
        }
Example #2
0
        public static List <Tuple <INeuralDataSet, INeuralDataSet> > GetCrossValidationData(List <Face> learningFaces, List <Face> testingFaces, int pairs)
        {
            int    testSize = learningFaces.Count;
            Random rnd      = new Random();
            List <Tuple <INeuralDataSet, INeuralDataSet> > crossValidation = new List <Tuple <INeuralDataSet, INeuralDataSet> >();
            List <Face> allData = new List <Face>();

            foreach (var f in learningFaces)
            {
                allData.Add(f);
            }
            foreach (var f in testingFaces)
            {
                allData.Add(f);
            }

            List <Face> tmpLearningFaces = new List <Face>();
            List <Face> tmpTestingFaces  = new List <Face>();

            for (int i = 0; i < pairs; i++)
            {
                tmpLearningFaces = new List <Face>();
                tmpTestingFaces  = new List <Face>();
                RandomizeSet(rnd, allData);
                for (int j = 0; j < allData.Count; j++)
                {
                    if (j < testSize)
                    {
                        tmpLearningFaces.Add(allData[j]);
                    }
                    else
                    {
                        tmpTestingFaces.Add(allData[j]);
                    }
                }
                double[][]     neuralLearningInput  = NetworkHelper.CreateLearningInputDataSet(tmpLearningFaces);
                double[][]     neuralLearningOutput = NetworkHelper.CreateLearningOutputDataSet(tmpLearningFaces, 4);
                INeuralDataSet learningSet          = NetworkHelper.NormaliseDataSet(neuralLearningInput, neuralLearningOutput);
                double[][]     neuralTestingInput   = NetworkHelper.CreateLearningInputDataSet(tmpTestingFaces);
                double[][]     neuralTestingOutput  = NetworkHelper.CreateLearningOutputDataSet(tmpTestingFaces, 4);
                INeuralDataSet testingSet           = NetworkHelper.NormaliseDataSet(neuralTestingInput, neuralTestingOutput);
                crossValidation.Add(new Tuple <INeuralDataSet, INeuralDataSet>(learningSet, testingSet));
            }

            return(crossValidation);
        }
Example #3
0
        public async Task PerformCalculation()
        {
            await Task.Run(() =>
            {
                Console.WriteLine("Szykuje dane zbioru uczacego");
                double[][] neuralLearningInput  = NetworkHelper.CreateLearningInputDataSet(learningFaces);
                double[][] neuralLearningOutput = NetworkHelper.CreateLearningOutputDataSet(learningFaces, 4);
                double[][] neuralTestingInput   = NetworkHelper.CreateLearningInputDataSet(testingFaces);
                double[][] neuralTestingOutput  = NetworkHelper.CreateLearningOutputDataSet(testingFaces, 4);
                INeuralDataSet learningSet, testingSet;

                learningSet = NetworkHelper.NormaliseDataSet(neuralLearningInput, neuralLearningOutput);
                testingSet  = NetworkHelper.NormaliseDataSet(neuralTestingInput, neuralTestingOutput);

                ITrain network = NetworkHelper.LearnNetwork(learningSet, testingSet, learningFaces[0].Features.Count, inputData, testingFaces.Count);
                learnedNetwork = network;
            });
        }