Guest User

Untitled

a guest
Jan 5th, 2018
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.94 KB | None | 0 0
  1. private void Ucz_Click(object sender, EventArgs e)
  2.         {
  3.             int iloscEpok = 0;
  4.             int aktual;
  5.             while (iloscEpok < 25000)
  6.             {
  7.                 aktual = -2;
  8.                 for(int i = 0; i < 10; i++)
  9.                 {
  10.                     //for (int x = 0; x < 10; x++) d[x] = 0.0;
  11.                     for (int j = 0; j < 10; j++)
  12.                     {
  13.                         for(int k = 0; k < 25; k++)
  14.                         {
  15.                             d[j] =d[j]+Math.Pow((daneUczace[i,k]-wagi[j,k]),2);
  16.                         }
  17.                         d[j] = Math.Sqrt(d[j]);
  18.                     }
  19.                     int min = 0;
  20.                     double mind = d[0];
  21.                     int mind2 = 0;
  22.                     for(int z = 1; z < 10; z++)
  23.                     {
  24.                         if (mind > d[z])
  25.                         {
  26.                             mind2 = min;
  27.                             mind = d[z];
  28.                             min = z;
  29.                         }
  30.                     }
  31.                    
  32.                     if (aktual != min)
  33.                     {
  34.                         aktual = min;
  35.                         best[i] = min;
  36.                         for (int s = 0; s < 25; s++)
  37.                         {
  38.                             wagi[best[i], s] = wagi[best[i], s] + alfa * (daneUczace[best[i], s] - wagi[best[i], s]);
  39.                         }
  40.                     }
  41.                     else
  42.                     {
  43.                         best[i] = mind2;
  44.                         for (int s = 0; s < 25; s++)
  45.                         {
  46.                             wagi[best[i], s] = wagi[best[i], s] + alfa * (daneUczace[best[i], s] - wagi[best[i], s]);
  47.                         }
  48.                     }
  49.                    
  50.                 }
  51.                 iloscEpok++;
  52.             }
  53.             textBox1.Text = "Wagi wyuczone";
  54.         }
Advertisement
Add Comment
Please, Sign In to add comment