Esempio n. 1
0
        public double DistInterNeurone(Neurone n2)
        {
            double dist = 0;

            for (int i = 0; i < poids.Count; i++)
            {
                dist = dist + (poids[i] - n2.poids[i]) * (poids[i] - n2.poids[i]);
            }
            return(Math.Sqrt(dist));
        }
Esempio n. 2
0
 public CarteSOM(int nbcol, int nblignes, int nbpoids, int valeurmax)
 {
     this.nbcol    = nbcol;
     this.nblignes = nblignes;
     tab           = new Neurone[nbcol, nblignes];
     for (int i = 0; i < nbcol; i++)
     {
         for (int j = 0; j < nblignes; j++)
         {
             tab[i, j] = new Neurone(nbpoids, valeurmax);
         }
     }
 }
Esempio n. 3
0
        private void button2_Click(object sender, EventArgs e)
        {
            listclasses.Clear();
            // Regroupement pour obtenir 2 classes
            SOM.regroupement(lobs, 6);
            pen.Color = Color.White;
            g.FillRectangle(pen.Brush, 0, 0, bmp.Width, bmp.Height);


            // pour chaque x,y de l'image
            // créer lobservation x,y
            // Pour chaque neurone neur de chaque classe k, trouver le gagnant
            // cad trouver le neurone qui minimise neur.calculerreur ( obs)
            // Colorer en fct de la classe

            List <Color> couleurs = new List <Color> {
                Color.Blue, Color.Red, Color.Green, Color.Orange, Color.DeepPink, Color.Purple
            };

            for (int i = 0; i < bmp.Width; i++)
            {
                for (int j = 0; j < bmp.Height; j++)
                {
                    Observation obs         = new Observation(i, j);
                    int         indexClasse = 0;
                    Neurone     neurChoisit = listclasses[0].GetNeurones()[0];
                    for (int k = 0; k < listclasses.Count; k++)
                    {
                        foreach (Neurone neur in listclasses[k].GetNeurones())
                        {
                            if (neur.CalculeErreur(obs) < neurChoisit.CalculeErreur(obs))
                            {
                                indexClasse = k;
                                neurChoisit = neur;
                            }
                        }
                    }

                    bmp.SetPixel(i, j, couleurs[indexClasse]);
                }
            }


            // Affichage final des 6 classes
            int x, y;

            pen.Color = Color.Blue;
            foreach (Neurone n in listclasses[0].GetNeurones())
            {
                x = Convert.ToInt32(n.GetPoids(0));
                y = Convert.ToInt32(n.GetPoids(1));
                g.DrawEllipse(pen, x - 2, y - 2, 4, 4);
            }

            pen.Color = Color.Red;
            foreach (Neurone n in listclasses[1].GetNeurones())
            {
                x = Convert.ToInt32(n.GetPoids(0));
                y = Convert.ToInt32(n.GetPoids(1));
                g.DrawEllipse(pen, x - 2, y - 2, 4, 4);
            }

            pen.Color = Color.Green;
            foreach (Neurone n in listclasses[2].GetNeurones())
            {
                x = Convert.ToInt32(n.GetPoids(0));
                y = Convert.ToInt32(n.GetPoids(1));
                g.DrawEllipse(pen, x - 2, y - 2, 4, 4);
            }

            pen.Color = Color.Orange;
            foreach (Neurone n in listclasses[3].GetNeurones())
            {
                x = Convert.ToInt32(n.GetPoids(0));
                y = Convert.ToInt32(n.GetPoids(1));
                g.DrawEllipse(pen, x - 2, y - 2, 4, 4);
            }

            pen.Color = Color.DeepPink;
            foreach (Neurone n in listclasses[4].GetNeurones())
            {
                x = Convert.ToInt32(n.GetPoids(0));
                y = Convert.ToInt32(n.GetPoids(1));
                g.DrawEllipse(pen, x - 2, y - 2, 4, 4);
            }

            pen.Color = Color.Purple;
            foreach (Neurone n in listclasses[5].GetNeurones())
            {
                x = Convert.ToInt32(n.GetPoids(0));
                y = Convert.ToInt32(n.GetPoids(1));
                g.DrawEllipse(pen, x - 2, y - 2, 4, 4);
            }

            AfficheDonnees();

            pictureBox1.Refresh();
        }
Esempio n. 4
0
 public Classe(Neurone neurone)
 {
     ListNeurones.Add(neurone);
 }