Beispiel #1
0
        public double TestNetwork(bool isInputNormalized = false)
        {
            if (!isInitialized)
            {
                return(-1);
            }

            DigitParser testDigitParser = new DigitParser(ResourceStorage.testDigitsPath);
            LabelParser testLabelParser = new LabelParser(ResourceStorage.testLabelsPath);

            double[] singleInput;
            double[] singleOutput;
            double[] networkOutput;
            int      corectOutputs = 0;
            int      totalOutputs  = testLabelParser.GetSampleCount();

            for (int i = 0; i < testDigitParser.GetSampleCount(); i++)
            {
                singleInput  = testDigitParser.GetNextInput();
                singleOutput = testLabelParser.GetNextOutput();

                if (isInputNormalized)
                {
                    NormalizeSingleInput(singleInput);
                }

                networkOutput = network.Compute(singleInput);
                if (singleOutput.SequenceEqual(ConvertToSingleOutput(networkOutput)))
                {
                    corectOutputs++;
                }
            }
            return((corectOutputs / (double)totalOutputs) * 100.0d);
        }
Beispiel #2
0
 private double[][] CreateEpochOutput()
 {
     double[][] result = new double[trainLabelParser.samplesCount][];
     for (int i = 0; i < trainLabelParser.samplesCount; i++)
     {
         result[i] = trainLabelParser.GetNextOutput();
     }
     return(result);
 }