AForge.NET

  :: AForge.NET Framework :: Articles :: Forums ::

backpropagation consistency

The forum is to discuss topics from different artificial intelligence areas, like neural networks, genetic algorithms, machine learning, etc.

backpropagation consistency

Postby serathes » Sun May 20, 2018 8:17 am

Hi everyone, I'm using backpropagation neural network for my school project.
I've successfully built the program which has 9 inputs, 2 outputs and 2 hidden layers using bipolar sigmoid function.
I take number of neurons for each hidden layer, learning rate, momentum and initializing values of weights from user
but my network is not consistent;
I get different results each time i train network with same parameters.
I've checked everything and only thing i can think of is threshold and documentation says threshold is not a member of "neuron" but "activationNeuron" and i can't access it like i do for weights; "network.Layers[i].Neurons[j]."
Is there any way to access and change threshold value of my neurons?
Or the cause of inconsistency is something else? ( checked my code hundred times ).

Any help is appreciated, thanks.
(I'm not a native English speaker so apologies in advance for any mistakes )

Code: Select all
ActivationNetwork network = new ActivationNetwork(
                new BipolarSigmoidFunction(1) , 9, (int)numericUpDown1.Value, (int)numericUpDown2.Value, 2);
            listBox1.Items.Add("training");
            BackPropagationLearning back = new BackPropagationLearning(network);
            back.LearningRate = (double)numericUpDown4.Value;
            back.Momentum = (double)numericUpDown5.Value;

            for (int i = 0; i < 3; i++)
            {
                for(int j = 0; j < network.Layers[i].Neurons.Length; j++)
                {
                    for(int k = 0; k< network.Layers[i].Neurons[j].Weights.Length; k++)
                    {
                        network.Layers[i].Neurons[j].Weights[k] = (double)numericUpDown3.Value;
                    }
                }
            }

            int epoch = 1;
            while ( epoch <= numericUpDown6.Value)
            {
                double error = back.RunEpoch(dataset1.inputs,dataset1.outputs);
                if (epoch % 100 == 0)
                {
                    listBox1.Items.Add("epoch:" + epoch + "   Error:" + error);
                    listBox1.SelectedIndex = listBox1.Items.Count - 1;
                    chart1.Series[0].Points.AddXY(epoch, Math.Round(error,4));
                }
                epoch++;
            }
serathes
 
Posts: 3
Joined: Sun May 20, 2018 7:44 am

Re: backpropagation consistency

Postby andrew.kirillov » Mon May 21, 2018 7:03 am

Hello,

Try something like this:
Code: Select all
( (ActivationNeuron) network.Layers[i].Neurons[j]).Threshold = 0.1;
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3370
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: backpropagation consistency

Postby serathes » Mon May 21, 2018 11:53 am

andrew.kirillov wrote:Hello,

Try something like this:
Code: Select all
( (ActivationNeuron) network.Layers[i].Neurons[j]).Threshold = 0.1;


Now it works perfectly, thank you so much.
serathes
 
Posts: 3
Joined: Sun May 20, 2018 7:44 am




Return to Artificial Intelligence

cron