/// <summary> /// Perform the specified neuron task. This task will be executed over all /// neurons. /// </summary> /// <param name="task">The task to perform.</param> public void PerformNeuronTask(FreeformNeuronTask task) { var visited = new HashSet <IFreeformNeuron>(); foreach (IFreeformNeuron neuron in _outputLayer.Neurons) { PerformNeuronTask(visited, neuron, task); } }
/// <summary> /// Perform the specified neuron task. /// </summary> /// <param name="visited">The visited list.</param> /// <param name="parentNeuron">The neuron to start with.</param> /// <param name="task">The task to perform.</param> private void PerformNeuronTask(HashSet <IFreeformNeuron> visited, IFreeformNeuron parentNeuron, FreeformNeuronTask task) { visited.Add(parentNeuron); task(parentNeuron); // does this neuron have any inputs? if (parentNeuron.InputSummation != null) { // visit the inputs foreach (IFreeformConnection connection in parentNeuron .InputSummation.List) { IFreeformNeuron neuron = connection.Source; // have we already visited this neuron? if (!visited.Contains(neuron)) { PerformNeuronTask(visited, neuron, task); } } } }
/// <summary> /// Perform the specified neuron task. /// </summary> /// <param name="visited">The visited list.</param> /// <param name="parentNeuron">The neuron to start with.</param> /// <param name="task">The task to perform.</param> private void PerformNeuronTask(HashSet<IFreeformNeuron> visited, IFreeformNeuron parentNeuron, FreeformNeuronTask task) { visited.Add(parentNeuron); task(parentNeuron); // does this neuron have any inputs? if (parentNeuron.InputSummation != null) { // visit the inputs foreach (IFreeformConnection connection in parentNeuron .InputSummation.List) { IFreeformNeuron neuron = connection.Source; // have we already visited this neuron? if (!visited.Contains(neuron)) { PerformNeuronTask(visited, neuron, task); } } } }
/// <summary> /// Perform the specified neuron task. This task will be executed over all /// neurons. /// </summary> /// <param name="task">The task to perform.</param> public void PerformNeuronTask(FreeformNeuronTask task) { var visited = new HashSet<IFreeformNeuron>(); foreach (IFreeformNeuron neuron in _outputLayer.Neurons) { PerformNeuronTask(visited, neuron, task); } }