Пример #1
0
        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBox1.Checked)
            {
                checkBox1.Text = "Stop";
            }
            else
            {
                checkBox1.Text = "Start";
            }
            Pattern p   = new Pattern();
            Random  rnd = new Random();
            int     iRnd;
            int     i = 0;

            double[] target = new double[10];
            while (checkBox1.Checked)
            {
                i++;
                iRnd = rnd.Next(0, 60000);
                TrainBaseMemStream.loadPattern(iRnd, p);
                for (int j = 0; j < 10; j++)
                {
                    target[j] = 0;
                }
                target[p.val] = 1;
                nNet.train(p.data, target);
                if (i % 50 == 0)
                {
                    this.Text = nNet.trainCount.ToString() + "/" + nNet.eta.ToString() + "/" + i.ToString();
                    Application.DoEvents();
                }
            }
        }
Пример #2
0
    /**
     * train the dataset
     * with "train" method on neuron network library, it takes 2 arguments:
     * dataset inputs and dataset targets as an array
     *
     * */
    void train()
    {
        for (int i = 0; i < 10; i++)
        {
            foreach (var data in list)
            {
                nn.train(data.inputs, data.targets);
            }
        }

        data_test();
    }
Пример #3
0
    void train()
    {
        data = new Dataset
        {
            inputs  = new float[] { 0, 0 },
            targets = new float[] { 0 },
        };

        data1 = new Dataset
        {
            inputs  = new float[] { 0, 1 },
            targets = new float[] { 1 },
        };

        data2 = new Dataset
        {
            inputs  = new float[] { 1, 0 },
            targets = new float[] { 1 },
        };

        data3 = new Dataset
        {
            inputs  = new float[] { 1, 1 },
            targets = new float[] { 0 },
        };

        list.Add(data);
        list.Add(data1);
        list.Add(data2);
        list.Add(data3);

        for (int i = 0; i < 20; i++)
        {
            foreach (var data in list)
            {
                nn.train(data.inputs, data.targets);
            }
        }
        trainTime++;
        data_test();
    }