/// <summary> /// Computes output value of neuron. /// </summary> /// /// <param name="input">An input vector.</param> /// /// <returns>Returns the neuron's output value for the given input.</returns> /// public override double Compute(double[] input) { double sum = threshold; for (int i = 0; i < weights.Length; i++) { sum += weights[i] * input[i]; } double output = function.Function(sum); this.output = output; return(output); }
/// <summary> /// Samples the neuron output considering /// the stochastic activation function. /// </summary> /// /// <param name="input">An input vector.</param> /// /// <returns>A possible output for the neuron drawn /// from the neuron's stochastic function.</returns> /// public double Generate(double[] input) { double sum = threshold; for (int i = 0; i < weights.Length; i++) { sum += weights[i] * input[i]; } double output = function.Function(sum); double sample = function.Generate2(output); this.output = output; this.sample = sample; return(sample); }