Note that there are some explanatory texts on larger screens.

plurals
  1. PONeuralNetwork back propagation question
    primarykey
    data
    text
    <p>After reading a lot of other peoples neural network code I am convinced something is not right with my code. It works and I can train a network its just that in order to train the next perceptron in the hidden layer I must train the last one, shouldn't I be able to train all the units in a hidden layer in parallel?</p> <p>Here is the code it calculates the error of the hidden layer:</p> <pre><code> for(int i=n-&gt;numOfPerceptronLayers-2;i&gt;=1;i--) { // for all hidden layers float sum = 0.0; // &lt;- This here is the problem for(int j=0;j&lt;n-&gt;perceptronLayers[i].numOfPerceptrons;j++) { // For all the units in the current hidden layer for(int k=0;k&lt;n-&gt;perceptronLayers[i].perceptrons[j].numOfConnections;k++) { // Loop through the current units connections to the previous layer (output layer) sum += n-&gt;perceptronLayers[i+1].perceptrons[k].error * n-&gt;perceptronLayers[i+1].perceptrons[k].weights[j]; } n-&gt;perceptronLayers[i].perceptrons[j].error = n-&gt;perceptronLayers[i].perceptrons[j].output * (1.0 - n-&gt;perceptronLayers[i].perceptrons[j].output) * sum; } } </code></pre> <p>It should be like this (but this doesn't work):</p> <pre><code>for(int i=n-&gt;numOfPerceptronLayers-2;i&gt;=1;i--) { // for all hidden layers for(int j=0;j&lt;n-&gt;perceptronLayers[i].numOfPerceptrons;j++) { // For all the units in the current hidden layer float sum = 0.0; for(int k=0;k&lt;n-&gt;perceptronLayers[i].perceptrons[j].numOfConnections;k++) { // Loop through the current units connections to the previous layer (output layer) sum += n-&gt;perceptronLayers[i+1].perceptrons[k].error * n-&gt;perceptronLayers[i+1].perceptrons[k].weights[j]; } n-&gt;perceptronLayers[i].perceptrons[j].error = n-&gt;perceptronLayers[i].perceptrons[j].output * (1.0 - n-&gt;perceptronLayers[i].perceptrons[j].output) * sum; } } </code></pre> <p>Why is it that the sum variable must be declared for the entire layer rather than a single perceptron?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload