Exemplo n.º 1
0
        public double[] Propagate(IList <Layer> layers, double[] input)
        {
            var inputLayer = layers.FirstOrDefault();

            int i = 0;

            foreach (var neuron in inputLayer.Neurons)
            {
                neuron.Value = input[i];
                i++;
            }

            foreach (var layer in layers.Skip(1))
            {
                foreach (var neuron in layer.Neurons)
                {
                    neuron.Value = neuron.Bias;
                    foreach (var previousNeuronDendrite in neuron.PreviousDendrites)
                    {
                        neuron.Value += previousNeuronDendrite.PreviousNeuron.Value * previousNeuronDendrite.Weight;
                    }
                    neuron.Value = _activationFunction.Count(neuron.Value);
                }
            }

            return(layers.Last().Neurons.Select(n => n.Value).ToArray());
        }