Discussion of article "Neural Networks Made Easy" - page 8

 

Hi Dmitriy,

I have been working on the first two parts of your "Neural Networks" Series for a few weeks now, and I keep comming accros the following code below when cycling through Neurons (or other things).

I really don't get it - in my view this would always leave out the last element. The Total() functions should return a count, then your remove one AND use "<" in the for loop. So for a Total() count of 2, you would only run the for loop once.

What am I missing?

Regards,

Delf


   int total=Layer.Total()-1;
   for(int n=0; n<total; n++)
     {
      CNeuron *neuron=Layer.At(n);
      resultVals.Add(neuron.getOutputVal());
     }
 

in some piece of codes you have written something like:

int total=Layer.Total()-1;
   for(int n=0; n<total; n++)
     {
      CNeuron *neuron=Layer.At(n);
      resultVals.Add(neuron.getOutputVal());
     }
  }

but assume we have 20 neurons in the layer, and we assign total variable with 19 [int total=Layer.Total()-1] so now total is equal to 19 , when we iterating over neurons from index 0-18 (total=19) we never reach the index 19 (last neuron), I think we must change the code with:

int total=Layer.Total();
   for(int n=0; n<=total; n++)
     {
      CNeuron *neuron=Layer.At(n);
      resultVals.Add(neuron.getOutputVal());
     }
  }

or

int total=Layer.Total()-1;
   for(int n=0; n<=total; n++)
     {
      CNeuron *neuron=Layer.At(n);
      resultVals.Add(neuron.getOutputVal());
     }
  }

to reach the last neuron on the layer.

what is you idea?

 
Hedayat Yazdani:

in some piece of codes you have written something like:

but assume we have 20 neurons in the layer, and we assign total variable with 19 [int total=Layer.Total()-1] so now total is equal to 19 , when we iterating over neurons from index 0-18 (total=19) we never reach the index 19 (last neuron), I think we must change the code with:

or

to reach the last neuron on the layer.

what is you idea?

At every layer we add one more neuron for bayesian shift. So at calling function to create layer with 20 neurons we creating 21 neurons. And Layer.Total() will return 21. But input data will has only 20 elements. Last bayesian neuron always have '1' in output. So I use Layer.Total()-1. In loop I use "<" because first element of the array has index '0'.

 
Good evening, I'd like to know if you can create Expert Advisor, Indicator or Script?
 
MetaQuotes:

New Article Neural Networks Made Easy has been released:

Written by Dmitriy Gizlyk

Hello, first time learning neural network, your article is very suitable for me, but I want to know why -1 is needed in many places, such as: nextLayer.Total () - 1, so that it does not match the number of neurons in the next layer .

 
Ping You Jiang #:

Hello, first time learning neural network, your article is very suitable for me, but I want to know why -1 is needed in many places, such as: nextLayer. () - 1, so that it does not match the number of neurons in the next layer .

Hi, it's normal work with array. At mql5 all array index start form 0. And nextLayer.Total() return total number of neurons. So if it back 10 that means elements of array have indexes from 0 to 9.

 

I actually get an compilation error when downloaded the file.

NeuroNet.mqh

 
Muhammad Saleem #:I actually get an compilation error when downloaded the file.

Try to use GetPointer function.

 
Dmitriy Gizlyk #: Try to use GetPointer function.

Hi Dmitriy, Thank for this article. Please for this error, how can one fix it? could you please provide the corrected code?

 
Muhammad Saleem #:I actually get an compilation error when downloaded the file.

Hi Muhammad, did you get to fix this error?