public void CheckOne()
        {
            ANeuralNetwork network = new ANeuralNetwork();

            network.Load("..\\..\\..\\..\\savedData.txt");
            var sampleDirs  = Directory.GetDirectories("..\\..\\..\\..\\Data\\TestData\\").ToList();
            int fCount      = Directory.GetFiles("..\\..\\..\\..\\Data\\GroundData\\", "*.png", SearchOption.AllDirectories).Length;
            var poliManager = new PolynomialManager();

            poliManager.InitBasis(15, 100);
            double count = 0;

            foreach (var dir in sampleDirs)
            {
                var files = Directory.GetFiles(dir, "*.png", SearchOption.TopDirectoryOnly).ToList();
                var index = new Random().Next(files.Count);
                var file  = files[index];
                var value = Convert.ToInt32(new StreamReader(dir + "\\" + "value.txt").ReadToEnd());

                ++count;
                ComplexMoments tmpMoments;
                ProcessOneImage(file, poliManager, 100, out tmpMoments);
                CvInvoke.Imshow(dir, tmpMoments.Real);
                var tmpInput = tmpMoments.ToListOfDouble();

                var output         = network.Predict(tmpInput);
                var predictedValue = Convert.ToInt32(output.IndexOf(output.Max()));

                Console.WriteLine(predictedValue);
                CvInvoke.WaitKey();
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            ANeuralNetwork tmp = new ANeuralNetwork();
            tmp.Load("..\\..\\..\\..\\PerceptronSavedData.txt");
            var line = Console.ReadLine();
            while (line!="q")
            {

                var tmpInput = line.Split().Select(double.Parse).ToList();
                var tmpOutput = tmp.Predict(tmpInput);
                foreach (var element in tmpOutput)
                {
                    Console.WriteLine(element);
                }

                line = Console.ReadLine();
            }
        }
        public void Check()
        {
            ANeuralNetwork network = new ANeuralNetwork();

            network.Load("..\\..\\..\\..\\savedData.txt");
            var    sampleDirs  = Directory.GetDirectories("..\\..\\..\\..\\Data\\TestData\\").ToList();
            int    fCount      = Directory.GetFiles("..\\..\\..\\..\\Data\\GroundData\\", "*.png", SearchOption.AllDirectories).Length;
            double precision   = 0;
            var    poliManager = new PolynomialManager();

            poliManager.InitBasis(15, 100);
            double count     = 0;
            double trueCount = 0;

            foreach (var dir in sampleDirs)
            {
                var files = Directory.GetFiles(dir, "*.png", SearchOption.TopDirectoryOnly).ToList();
                var value = Convert.ToInt32(new StreamReader(dir + "\\" + "value.txt").ReadToEnd());

                foreach (var file in files)
                {
                    ++count;
                    ComplexMoments tmpMoments;
                    ProcessOneImage(file, poliManager, 100, out tmpMoments);
                    var tmpInput = tmpMoments.ToListOfDouble();

                    var output         = network.Predict(tmpInput);
                    var predictedValue = Convert.ToInt32(output.IndexOf(output.Max()));
                    if (predictedValue == value)
                    {
                        //++trueCount;
                        precision += Convert.ToDouble(100 / (double)fCount);
                    }
                }

                Console.WriteLine("Точность " + precision + "%");
                //Console.WriteLine("Точность " + trueCount/count + "%");
            }
        }