Exemplo n.º 1
0
        //private void BTN_CLASSIFY_Click(object sender, EventArgs e)
        //{
        //    ClassifySpace();
        //}

        private void ClassifySpace()
        {
            double value;

            for (int x = -35; x < 35; x++)
            {
                for (int y = -35; y < 35; y++)
                {
                    if (x == 1 && y == 1)
                    {
                        Console.Write("here");
                    }
                    if (x == -1 && y == 1)
                    {
                        Console.Write("here");
                    }

                    value = net.ComputeNetworkOutput(new Input(new double[] { x, y }, new double[] { 1 }))[0];
                    PaintPoint(x, y, value);
                }
            }
            PaintInput();

            MyDelegates.SetBMPValue(PCT_CANVAS, canvas);
        }
Exemplo n.º 2
0
        private void BuildNet()
        {
            List <Layer> layers;
            int          hiddenNuerons, it;
            double       rate, lower;
            double       error;
            FunctionType Ftype;

            layers        = new List <Layer>();
            hiddenNuerons = 7;
            rate          = 0.5;
            Ftype         = FunctionType.SIGMOID;

            layers.Add(new Layer(inputs[0].Features.Length, inputs[0].Features.Length, rate, Ftype));
            layers.Add(new Layer(hiddenNuerons, layers[layers.Count - 1].Neurons.Length, rate, Ftype));
            layers.Add(new Layer(inputs[0].DesiredValue.Length, layers[layers.Count - 1].Neurons.Length, rate, Ftype));

            net = new NeuralNetwork(layers.ToArray());
            net.SetTrainSet(inputs.ToArray());

            error = double.MaxValue;
            lower = double.MaxValue;

            it = 0;
            while (error > 0.001 && it++ < 10000000)
            {
                error = net.Train();
                if (error < lower)
                {
                    lower = error;
                }
                if (it % 50 == 0)
                {
                    MyDelegates.SetTextValue(LBL_IT, "epochs : " + it);
                    MyDelegates.SetTextValue(LBL_ERROR, "Error : " + Math.Round(error, 5));
                    MyDelegates.SetTextValue(LBL_LOWEST, "Lowest : " + Math.Round(lower, 9));
                }

                if (it % 1000 == 0)
                {
                    try
                    {
                        ClassifySpace();
                    }catch (Exception) {}
                }
            }
        }