public double GetAllDeltas(Synapse synapse) { double delta = 0; foreach (var nextSynapse in synapse.NeuronTo.Outputs) { delta += nextSynapse.Delta; if (nextSynapse.NeuronTo.Outputs.Count != 0) { for (int i = 0; i < nextSynapse.NeuronTo.Outputs.Count; i++) { delta += GetAllDeltas(nextSynapse.NeuronTo.Outputs[i]); } } } return(delta); }
public void ConnectLayers(NetworkLayer previous) { Random random = new Random(); foreach (Neuron pvNeuron in previous.NetworkNeurons) { List <Synapse> newConnections = new List <Synapse>(); foreach (Neuron nextNeuron in this.NetworkNeurons) { double k = random.NextDouble(); Synapse newSynapse = new Synapse(pvNeuron, nextNeuron, k / 10); nextNeuron.Inputs.Add(newSynapse); newConnections.Add(newSynapse); } pvNeuron.Outputs = newConnections; } }