Esempio n. 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);
        }
Esempio n. 2
0
 private double[][] CreateEpochInput()
 {
     double[][] result = new double[trainDigitParser.samplesCount][];
     for (int i = 0; i < trainDigitParser.samplesCount; i++)
     {
         result[i] = trainDigitParser.GetNextInput();
     }
     return(result);
 }