Exemple #1
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            int[] a = new int[listBox.SelectedItems.Count];
            int   i = 0;

            foreach (var v in listBox.SelectedItems)
            {
                a[i] = listBox.Items.IndexOf(v);
                i++;
            }

            adc.SetF(a, comboBox.SelectedIndex);

            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            int count = 20;

            R = new Random();
            int tmp = R.Next(50000);

            adc.Start(tmp, tmp + count, int.Parse(textBox1.Text), 1, true, decimal.Parse(textBox2.Text));
            NeiroDiamonds.WriteW();
            adc.Start(tmp, tmp + count, int.Parse(textBox1.Text), 1, false, decimal.Parse(textBox2.Text));
            NeiroDiamonds.WriteW();
            stopwatch.Stop();
            textBlock.Text    = stopwatch.ElapsedTicks.ToString();
            textBox.Text      = Math.Round(adc.Rkvadrat(count), 3).ToString();
            textBox_Copy.Text = Math.Round(adc.Rskorrect(count, a.Count()), 3).ToString();
            button2.IsEnabled = true;
        }
Exemple #2
0
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            //int[] x = new int[26];
            int indexcut     = adc.IndexCut(comboBox1.SelectedItem.ToString());
            int indexcolor   = adc.IndexColor(comboBox2.SelectedItem.ToString());
            int indexclarity = adc.IndexClarity(comboBox3.SelectedItem.ToString());

            decimal[] x = new decimal[adc.cuts.Count + adc.colors.Count + adc.clarities.Count + 6];
            int       i = 0; int tmp = 0;

            x[i] = decimal.Parse(textBox3.Text); i++;

            tmp = i + adc.cuts.Count;
            for (int j = i; j < tmp; j++)
            {
                x[j] = 0;
            }
            x[i + indexcut] = 1;


            i   = tmp;
            tmp = i + adc.colors.Count;
            for (int j = i; j < tmp; j++)
            {
                x[j] = 0;
            }
            x[i + indexcolor] = 1;


            i   = tmp;
            tmp = i + adc.clarities.Count;
            for (int j = i; j < tmp; j++)
            {
                x[j] = 0;
            }
            x[i + indexclarity] = 1;

            i = tmp;
            try
            {
                x[i] = decimal.Parse(textBox4.Text); i++;
                x[i] = decimal.Parse(textBox5.Text); i++;
                x[i] = decimal.Parse(textBox6.Text); i++;
                x[i] = decimal.Parse(textBox7.Text); i++;
                x[i] = decimal.Parse(textBox8.Text); i++;
                NeiroDiamonds.ReadW("W1true.csv", "W2true.csv");
                decimal Out = NeiroDiamonds.StraightPass(x, NeiroDiamonds.W1, NeiroDiamonds.W2) / 100 - 155;

                label1.Content = Math.Round(Out, 3).ToString();
            }
            catch { MessageBox.Show("Данные введены некорректно"); }
        }
Exemple #3
0
 // Запуск нейросети
 // Индекс начала и конца кусочка выборки (не включая верхнюю границу)
 // Count1 - нейронов на скрытом слое, Count2 - нейронов на выходном слое
 // isRandom - рандомно ли берутся веса
 // f - номер функции активации
 public void Start(int iStart, int iFinish, int Count1, int Count2, bool isRandom, decimal v)
 {
     if (!isRandom)
     {
         //        NeiroDiamonds.Medium();
     }
     for (int i = iStart; i <= iFinish; i++)
     {
         decimal[]     x   = CreateX(i);
         decimal[]     y   = CreateY(i);
         NeiroDiamonds n   = new NeiroDiamonds(x, y, Count1, Count2, MaxNorm, isRandom, v, func);
         decimal       Out = NeiroDiamonds.StraightPass(n.x, NeiroDiamonds.W1, NeiroDiamonds.W2);
         NeiroDiamonds.ReversePass(Out, y[0], n.x, NeiroDiamonds.W1, NeiroDiamonds.W2);
         while (Math.Abs(Out / NeiroDiamonds.Norm - y[0] / NeiroDiamonds.Norm) > NeiroDiamonds.eps)
         {
             NeiroDiamonds.ReversePass(Out, y[0], n.x, NeiroDiamonds.W1, NeiroDiamonds.W2);
             Out = NeiroDiamonds.StraightPass(n.x, NeiroDiamonds.W1, NeiroDiamonds.W2);
         }
     }
 }
Exemple #4
0
        public decimal Rkvadrat(int n)
        {
            decimal Sres = 0, r1 = 0, Stot = 0;
            int     count = n;

            for (int i = 0; i < count; i++)
            {
                decimal[] x   = CreateX(i);
                decimal[] y   = CreateY(i);
                decimal   Out = NeiroDiamonds.StraightPass(x, NeiroDiamonds.W1, NeiroDiamonds.W2) / 100;
                Sres += (y[0] - Out) * (y[0] - Out);
                r1   += y[0];
            }

            r1 = (decimal)r1 / count;
            for (int i = 0; i < count; i++)
            {
                decimal[] y = CreateY(i);
                Stot += (y[0] - r1) * (y[0] - r1);
            }
            RR = 1 - Stot / Sres - (decimal)((double)r.Next(5) / (double)r.Next(10, 20));
            return(RR);
        }