コード例 #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);
        }
コード例 #2
0
 public void SetTrainingPaths(string inputPath, string outputPath)
 {
     trainDigitParser = new DigitParser(inputPath);
     trainLabelParser = new LabelParser(outputPath);
     isInitialized    = true;
 }