Esempio n. 1
0
        /// <summary>
        /// This receives an input signal from the input axon.  It then
        /// initializes the set of missing inputs (if necessary) with the
        /// ids of the input axons.  If the axon is one of the axons that
        /// has not sent its signal, it is removed from the set of
        /// missing axons and the input value is stored.  If the size of the
        /// missing input set drops to zero, the output value is calculate,
        /// and the neuron is fired.
        /// </summary>
        /// <param name="firingAxon">The axon sending signal</param>
        /// <param name="val">The value firing into this neuron</param>
        public virtual void ReceiveSignal(Axon firingAxon, double val)
        {
            if (missingInput == null)
            {
                missingInput = new Dictionary <Guid, Guid>();
                foreach (Guid id in inputAxonIds)
                {
                    missingInput[id] = id;
                }
                //missingInput.AddRange(inputAxonIds);
            }

            if (missingInput[firingAxon.Id] != null)
            {
                inputs[inputAxonIds.IndexOf(firingAxon.Id)] = val;
                //inputs[(int)(inputAxonIndexes[firingAxon.Id])] = val;
                missingInput.Remove(firingAxon.Id);
            }

            if (missingInput.Count == 0)
            {
                rawValue    = DotProduct(inputs, Weights);
                outputValue = activation.Activation(rawValue);
                FireNeuron();
                missingInput = null;
            }
        }
Esempio n. 2
0
    public override float GetValue()
    {
        float sum = 0;

        foreach (Connection c in connections)
        {
            sum += c.GetValue();
        }
        value = activationFunction.Activation(sum);

        return(value);
    }
Esempio n. 3
0
 public override float GetValue()
 {
     return(activationFunction.Activation(value));
 }