// Might want to move into a co-routine as this might become very large and expensive. private IEnumerator CoFeedForward() { yield return(new WaitForEndOfFrame()); // Update the Input layer with updated inputs. for (int i = 0; i < LayerNeuronCounts[0]; ++i) { NetLayers[0].Nodes[i].Activation = Inputs[i]; if (ShouldYield()) { yield return(new WaitForEndOfFrame()); } } // Go through each layer that isn't the input layer. for (int i = 1; i < NumLayers; ++i) { // Go through each node in this layer and calculate it's activation value. for (int j = 0; j < LayerNeuronCounts[i]; ++j) { SigmoidNeuron tempNeuron = NetLayers[i].Nodes[j]; tempNeuron.Activation = Sigmoid(tempNeuron.GetZ()); if (ShouldYield()) { yield return(new WaitForEndOfFrame()); } } } // Update the outputs from the output layer. for (int i = 0; i < LayerNeuronCounts[NumLayers - 1]; ++i) { Outputs[i] = NetLayers[NumLayers - 1].Nodes[i].Activation; if (ShouldYield()) { yield return(new WaitForEndOfFrame()); } } for (int i = 0; i < FeedforwardCallBacks.Count; ++i) { if (FeedforwardCallBacks[i] != null) { FeedforwardCallBacks[i](); } } }
public void FeedForward() { for (int i = 0; i < LayerNeuronCounts[0]; ++i) { NetLayers[0].Nodes[i].Activation = Inputs[i]; } // Go through each layer that isn't the input layer. for (int i = 1; i < NumLayers; ++i) { // Go through each node in this layer and calculate it's activation value. for (int j = 0; j < LayerNeuronCounts[i]; ++j) { SigmoidNeuron tempNeuron = NetLayers[i].Nodes[j]; tempNeuron.Activation = Sigmoid(tempNeuron.GetZ()); } } // Update the outputs from the output layer. for (int i = 0; i < LayerNeuronCounts[NumLayers - 1]; ++i) { Outputs[i] = NetLayers[NumLayers - 1].Nodes[i].Activation; } }