コード例 #1
0
        public ReadMnist(bool isNeedTrain, bool isNeedTest)
        {
            FormConsole.PrintlnAndScroll("Read Mnist Start....");
            if (isNeedTrain)
            {
                string trainImagesPath = @"mnist\train-images.idx3-ubyte";
                string trainLabelsPath = @"mnist\train-labels.idx1-ubyte";
                int    trainPattCount  = 60000 /*60000*/;
                trainDigits = ReadMnistFromFiles(trainImagesPath, trainLabelsPath, trainPattCount, 28, 28);
                FormConsole.PrintlnAndScroll("Read trainDigits Finish");
                Thread.Sleep(TimeSpan.FromMilliseconds(2000));
            }
            if (isNeedTest)
            {
                string testImagesPath = @"mnist\t10k-images.idx3-ubyte";
                string testLabelsPath = @"mnist\t10k-labels.idx1-ubyte";

                /*string testImagesPath = @"mnist\train-images.idx3-ubyte";
                *  string testLabelsPath = @"mnist\train-labels.idx1-ubyte";*/
                int testPattCount = 10000 /*10000*/;
                testDigits = ReadMnistFromFiles(testImagesPath, testLabelsPath, testPattCount, 28, 28);
                FormConsole.PrintlnAndScroll("Read testDigits Finish");
                Thread.Sleep(TimeSpan.FromMilliseconds(2000));
            }
            FormConsole.PrintlnAndScroll("Read Mnist Finish");
            Thread.Sleep(TimeSpan.FromMilliseconds(2000));
        }
コード例 #2
0
        //Тест количество верных ответов для mnist TestDigits
        public void MnistTest(ReadMnist readMnist, List <List <float> > answers)
        {
            FormConsole.PrintlnAndScroll("\r\nstart Mnist Test");
            int testCount = readMnist.TestDigits.Count;
            int goodCount = 0;

            for (int i = 0; i < testCount; i++)
            {
                List <float> input = readMnist.TestDigits[i].floatPixels;
                if (IsBiasNeuron)
                {
                    input.Add(1);
                }
                int          label  = readMnist.TestDigits[i].label;
                List <float> output = Run(input, IsBiasNeuron);
                if (IsCorrectAnswer(output, answers[label]))
                {
                    goodCount++;
                }
                if (i % 100 == 0)
                {
                    FormConsole.PrintlnAndScroll("i = " + i + " goodCount = " + goodCount);
                }
            }
            FormConsole.PrintlnAndScroll("goodCount = " + goodCount
                                         + "\r\nfinish Mnist Test");
        }
コード例 #3
0
        //Тест количество верных ответов для mnist TestDigits
        public void FormatTest(PatternsType patterns, KeysType keys, AnswersType answers)
        {
            FormConsole.PrintlnAndScroll("\r\nstart Format Test");
            int testCount = patterns.Count;
            int goodCount = 0;

            int[] pattSuccess = new int[answers.Count];
            for (int i = 0; i < testCount; i++)
            {
                List <float> input = patterns[i];
                if (IsBiasNeuron && input.Count != this.inputLayer.SizeNeurons)
                {
                    input.Add(1);
                }
                string       label  = keys[i];
                List <float> output = Run(input, IsBiasNeuron);
                if (IsCorrectAnswer(output, answers[label]))
                {
                    goodCount++;
                    int num = 0;
                    if (int.TryParse(label, out num))
                    {
                        pattSuccess[num]++;
                    }
                }
                if (i % 1000 == 0)
                {
                    FormConsole.PrintlnAndScroll("i = " + i + " goodCount = " + goodCount);
                }
            }
            FormConsole.PrintlnAndScroll("goodCount = " + goodCount
                                         + "\r\nfinish Mnist Test");
            for (int i = 0; i < pattSuccess.Length; i++)
            {
                FormConsole.AppendText(i + ": " + pattSuccess[i].ToString() + "\r\n");
            }
        }