/// <summary> /// Get the magnitude of the specified input. /// </summary> /// <param name="input">The input to calculate the magnitude for.</param> /// <returns>The magnitude of the specified pattern.</returns> public double Magnitude(BiPolarNeuralData input) { double result; result = 0; for (int i = 0; i < this.layerF1.NeuronCount; i++) { result += input.GetBoolean(i) ? 1 : 0; } return result; }
/// <summary> /// Set the input to the neural network. /// </summary> /// <param name="input">The input.</param> private void SetInput(BiPolarNeuralData input) { double activation; for (int i = 0; i < this.layerF1.NeuronCount; i++) { activation = (input.GetBoolean(i) ? 1 : 0) / (1 + this.a1 * ((input.GetBoolean(i) ? 1 : 0) + this.b1) + this.c1); this.outputF1.SetBoolean(i, (activation > 0)); } }
/// <summary> /// Compute the output from the F1 layer. /// </summary> /// <param name="input">The input to the F1 layer.</param> private void ComputeF1(BiPolarNeuralData input) { double sum, activation; for (int i = 0; i < this.layerF1.NeuronCount; i++) { sum = this.synapseF1toF2.WeightMatrix[i, this.winner] * (this.outputF2.GetBoolean(this.winner) ? 1 : 0); activation = ((input.GetBoolean(i) ? 1 : 0) + this.d1 * sum - this.b1) / (1 + this.a1 * ((input.GetBoolean(i) ? 1 : 0) + this.d1 * sum) + this.c1); this.outputF1.SetBoolean(i, activation > 0); } }