コード例 #1
0
        /// <summary>
        /// Renvoie le voisinage du gagnant
        /// </summary>
        /// <param name="gagnant"></param>
        /// <param name="totalIteration"></param>
        /// <param name="iterationCourante"></param>
        /// <returns></returns>
        private List <KohonenNeurone> Voisinage(KohonenNeurone gagnant, int totalIteration, int iterationCourante)
        {
            // on commence par calculer le rayon
            double rayon = FonctionsAttenuation.Sigma(RayonCarte, totalIteration, iterationCourante);

            // on recherche les neurones présents dans le rayon
            // leurs poids seront ajustés
            List <KohonenNeurone> voisinage = new List <KohonenNeurone>();

            for (int x = 0; x < Grille.GetLength(0); x++)
            {
                for (int y = 0; y < Grille.GetLength(1); y++)
                {
                    KohonenNeurone neurone = Grille[x, y];
                    neurone.Distance = Distance(neurone, gagnant);

                    if (neurone.Distance <= rayon)
                    {
                        voisinage.Add(neurone);
                    }
                }
            }

            Debug.WriteLine("Voisinage: " + voisinage.Count.ToString());
            return(voisinage);
        }
コード例 #2
0
ファイル: Kohonen.cs プロジェクト: panichevad/NeuralNetwork
        /// <summary>
        /// Sauvegarde un réseau de Kohonen 2D dans un bitmap
        /// </summary>
        /// <param name="name">Nom du fichier sans extension ni chemin</param>
        public string ToBitmap(string name)
        {
            int X = Grille.GetLength(0);
            int Y = Grille.GetLength(1);

            Bitmap bitMap = new Bitmap(X, Y);

            for (int x = 0; x < X; x++)
            {
                for (int y = 0; y < Y; y++)
                {
                    Neurone neurone = Grille[x, y];
                    Color couleur = Color.FromArgb((int)neurone.Poids[0], (int)neurone.Poids[1], (int)neurone.Poids[2]);

                    bitMap.SetPixel(x, y, couleur);
                }
            }

            string modele = @"c:\temp\{0}.bmp";
            string fichier = string.Format(modele, name);
            bitMap.Save(fichier);

            return fichier;
        }