public static NeuralNetwork Child(NeuralNetwork mum, NeuralNetwork dad)
        {
            NeuralNetwork child = new NeuralNetwork(mum);

            for (int i = 0; i < child.Length; i++)
            {
                for (int j = 0; j < child[i].Length; j++)
                {
                    for (int k = 0; k < child[i][j].Length; k++)
                    {
                        float value = child[i][j][k].x;

                        int rand = RandomF.Next(2);
                        if (rand == 0)
                        {
                            value = dad[i][j][k].x;
                        }
                        child[i][j][k].x = value;
                    }
                }
                if (!child[i].IsBiasNull())
                {
                    for (int k = 0; k < child[i].GetBias().Length; k++)
                    {
                        float value = child[i].GetBias()[k].x;

                        int rand = RandomF.Next(2);
                        if (rand == 0)
                        {
                            value = dad[i].GetBias()[k].x;
                        }
                        child[i].GetBias()[k].x = value;
                    }
                }
            }

            return(child);
        }
示例#2
0
        private void formUI_Load(object sender, EventArgs e)
        {
            ToolTip toolTip = new ToolTip();

            months.Add("January");
            months.Add("February");
            months.Add("March");
            months.Add("April");
            months.Add("May");
            months.Add("June");
            months.Add("July");
            months.Add("August");
            months.Add("September");
            months.Add("October");
            months.Add("November");
            months.Add("December");

            string path = @"images\";

            string[] lines = File.ReadAllLines(path + "data.txt");
            linesList.AddRange(lines);

            for (int i = 0; i < lines.Length; i++)
            {
                string[] split = lines[i].Split(' ');

                string name = split[0];

                PictureBox pictureBoxPoster = new PictureBox()
                {
                    Name     = Path.GetFileName(name),
                    Location = new Point((int)Map.Float(0f,
                                                        RandomF.NextFloat(this.Width),
                                                        this.Width,
                                                        this.Width * padding,
                                                        this.Width - (this.Width * padding) - size.Width),
                                         RandomF.Next(this.Height - size.Height)),
                    Image       = Image.FromFile(path + name),
                    Size        = size,
                    SizeMode    = PictureBoxSizeMode.StretchImage,
                    Tag         = i.ToString(),
                    BorderStyle = BorderStyle.FixedSingle
                };

                pictureBoxPoster.MouseDown += PictureBoxPoster_MouseDown;
                pictureBoxPoster.MouseUp   += PictureBoxPoster_MouseUp;
                pictureBoxPoster.MouseMove += PictureBoxPoster_MouseMove;

                toolTip.SetToolTip(pictureBoxPoster, split[0]);

                pictureBoxes.Add(pictureBoxPoster);
                this.Controls.Add(pictureBoxPoster);

                // Categories
                string[] categoriesArr = split[4].Split(',');
                for (int j = 0; j < categoriesArr.Length; j++)
                {
                    if (!categories.Contains(categoriesArr[j]))
                    {
                        categories.Add(categoriesArr[j]);
                    }
                }

                // Directors
                string[] directorsArr = split[5].Split(',');
                for (int j = 0; j < directorsArr.Length; j++)
                {
                    if (!directors.Contains(directorsArr[j]))
                    {
                        directors.Add(directorsArr[j]);
                    }
                }

                // Stars
                string[] starsArr = split[6].Split(',');
                for (int j = 0; j < starsArr.Length; j++)
                {
                    if (!stars.Contains(starsArr[j]))
                    {
                        stars.Add(starsArr[j]);
                    }
                }
            }

            neuralNetwork = new NeuralNetwork(31 + 12 + 1 + categories.Count + directors.Count + stars.Count, 64, 1)
            {
                max_circle    = 10000,
                learning_rate = 0.5f,
                momentum_rate = 0.96f
            };
        }