bmhoang / aforge

Automatically exported from code.google.com/p/aforge
Other
0 stars 0 forks source link

Loop base on array, not cross the row of array. #352

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Describe the feature you are interested and which may bring benefit to the
project ...

public class BackPropagationLearning : ISupervisedLearning

private double CalculateError( double[] desiredOutput )
{
......
 // for all neurons of the layer
 for ( int i = 0; i < layer.Neurons.Length; i++ )
 {
     sum = 0.0;
     // for all neurons of the next layer
     for ( int k = 0; k < layerNext.Neurons.Length; k++ )
     {
         sum += errorsNext[k] * layerNext.Neurons[k].Weights[i];
     }
     errors[i] = sum * function.Derivative2( layer.Neurons[i].Output );
 }

In case the length of neurons.weights is more than 512 (8B*512 = 32K for X86 
CPU),
The performance of loop K will be bad.

We should create a sum[] array to calculate all sum order by the sequence of 
weights.

Original issue reported on code.google.com by ChinaTo...@gmail.com on 5 Aug 2013 at 11:35