With the cyclic network each neuron has two state variables associated with it:
neuron.InputValue
neuron.OutputValue
And each connection references both the source and target neuron objects:
connection.SourceNeuron
connection.TargetNeuron
A single iteration of the whole network consists of:
// Loop connections.
foreach(Connection connection)
{
// connection.SourceNeuron.OutputValue here is the output signal
from the previous iteration, so for hidden neurons this is zero to
start with, and for input neurons it is the input values to the
network as a whole.
double connectionOutput = connection.Weight *
connection.SourceNeuron.OutputValue;
// Sum/accumulate the connection output signals onto their target neurons.
connection.TargetNeuron.InputValue += connectionOutput;
}
// Loop neurons (hidden and output neurons only).
foreach(Neuron neuron)
{
// Apply activation function to the accumulated input signal at
each neuron, thus obtaining each neuron's output signal ready for the
next iteration.
neuron.OutputValue = activationFunction(neuron.InputValue);
// Reset/zero the input value now that this iteration is over
with , i.e. InputValue is a working state variable for use within each
iteration only.
neuron.InputValue = 0.0
}
So there's a two stage process, one where neuron output signals from
the previous timestep are propagated to their target neurons, and
another that applies the activation function to get updated neuron
output signals for the current timestep. Then the process repeats for
however many timesteps are required/configured.
This is very different to the acyclic network in which each neuron is
located in a layer and is activated only once as activation progresses
down the layers. In the cyclic network all of the neurons's are
activated simultaneously at each timestep, using neuron output values
from the previous timestep as the input values for the current
timestep.
That is the intention and I believe the code is correct with respect
to that intention.
> So shouldn't the line in second nested loop be like this:
> neuron.InputValue = neuron.OutputValue;
At the start of each iteration/timestep each neuron's state is in
OutputValue, that is the one and only activation level for each
neuron. InputValue exists as a temporary/intermediate state variable
at each neuron for holding the pre-activation level of the neuron.
This is necessary because we need to separate the pre and post
activation levels of each neuron because all of the neurons are
effectively being activated simultaneously. I.e. we need to keep a
copy of the activation level from the previous timestep until we are
sure it is no longer needed (i.e. until we finish the first loop -
over the connections).
So I think the issue here is that your understanding of the intent is
off slightly, rather than there being an error in the core per se.
What do you think?
Colin