コード例 #1
0
        private void TreningEpoki()
        {
            nrEpok++;
            Shuffle(trainings);
            //Trening jednej epoki
            for (int i = 0; i < trainings.Count; i++)
            {
                OneDraw  data   = trainings[i];
                double[] inputs = data.BrightPixels;

                //normalizacja danych tu moze byc

                Label    name    = trainings[i].Lbl;
                double[] targets = new double[ileKategorii];
                for (int k = 0; k < ileKategorii; k++)
                {
                    targets[k] = 0;
                }
                targets[(int)name] = 1;
                nn.Train(inputs, targets);
                double wartProcent = ((double)(i + 1) / (double)trainings.Count()) * 100;

                this.InvokeIfRequired((value) => progressBar.Value = (int)wartProcent, 10);
            }
            this.InvokeIfRequired((value) => listBox1.Items.Add("Zakonczono nauczanie epoki: " + nrEpok), 10);
            th.Abort();
        }
コード例 #2
0
        private void TestingAll()
        {
            Shuffle(testings);
            int correct = 0;

            //Trening jednej epoki
            for (int i = 0; i < testings.Count; i++)
            {
                OneDraw  data     = testings[i];
                double[] inputs   = data.BrightPixels;
                Label    name     = testings[i].Lbl;
                double[] guess    = nn.Guess(inputs);
                double   maxValue = guess.Max();
                int      pom      = guess.ToList().IndexOf(maxValue);
                Label    guessLbl = 0;
                guessLbl += pom;
                if ((int)guessLbl == (int)data.Lbl)
                {
                    correct++;
                }
            }
            double percent = ((double)correct / (double)testings.Count()) * 100;

            listBox1.Items.Add("Dokladnosc nauki: " + percent.ToString() + "%");
        }
コード例 #3
0
        private void Shuffle(List <OneDraw> list)
        {
            Random rng = new Random();
            int    n   = list.Count;

            while (n > 1)
            {
                n--;
                int     k     = rng.Next(n + 1);
                OneDraw value = list[k];
                list[k] = list[n];
                list[n] = value;
            }
        }
コード例 #4
0
        private void btnZgadnij_Click(object sender, EventArgs e)
        {
            Bitmap  bmp     = (Bitmap)PictureBox.Image;
            Bitmap  resized = new Bitmap(bmp, new Size(bmp.Width / 10, bmp.Height / 10));
            OneDraw rysunek = new OneDraw(resized);

            double[] rysunekInputs = rysunek.BrightPixels;

            double[] guess    = nn.Guess(rysunekInputs);
            double   maxValue = guess.Max();
            int      pom      = guess.ToList().IndexOf(maxValue);
            //Label guessLbl = Label.airplanes;
            Label guessLbl = 0;

            guessLbl += pom;
            listBox1.Items.Add("Myślę, że jest to: " + guessLbl);
        }