Exemple #1
0
        void buttonBackpropagation_Click(object sender, EventArgs e)
        {
            foreach (var classImages in images)
            {
                var output = new double[classImages.Count][];
                var img    = new double[classImages.Count][];
                for (var i = 0; i < classImages.Count; i++)
                {
                    img[i] = classImages[i].GetImageAsArray();
                    for (var j = 0; j < classImages.Count; j++)
                    {
                        output[i] = new double[classImages.Count];
                    }
                    for (var j = 0; j < classImages.Count; j++)
                    {
                        if (i == j)
                        {
                            output[i][j] = 1;
                        }
                        else
                        {
                            output[i][j] = 0;
                        }
                    }
                }

                var network = new Backpropagation(img[0].Length, 200, classImages.Count);
                network.Train(img, output);
                backpropagation.Add(network);
                network.SaveWeights($"perceptron{images.IndexOf(classImages)}.bp");
            }

            MessageBox.Show("Yeeeey");
        }
Exemple #2
0
        void ButtonLoadWeights_Click(object sender, EventArgs e)
        {
            var openFileDialog = new OpenFileDialog();

            openFileDialog.Multiselect      = false;
            openFileDialog.Filter           = "bp (*.bp)|*.bp";
            openFileDialog.InitialDirectory = Directory.GetCurrentDirectory();
            openFileDialog.Multiselect      = true;
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                if (openFileDialog.FileNames.Length == 1)
                {
                    var network = new Backpropagation();
                    network.LoadWeights(openFileDialog.FileName);
                    backpropagation.Add(network);
                }
                else
                {
                    foreach (var fileName in openFileDialog.FileNames)
                    {
                        var network = new Backpropagation();
                        network.LoadWeights(fileName);
                        backpropagation.Add(network);
                    }
                }
            }
        }