예제 #1
0
        /// <summary>
        /// Calculates the Output for a given Input using the Sigmoid Function.
        /// </summary>
        /// <param name="passedInput">The Input.</param>
        /// <param name="passedThreshold">The Threshold.</param>
        /// <returns>The Output for the Sigmoid Function.</returns>
        public INeuronOutput CalculateOutput(INeuronActivationFunctionInput passedInput, INeuronThreshold passedThreshold)
        {
            float         resultValue = (float)(1 / (1 + Math.Exp((-passedInput.Value) / passedThreshold.Value)));
            INeuronOutput result      = new NeuronOutput(resultValue);

            return(result);
        }
예제 #2
0
        /// <summary>
        /// Calculates the Output for a given Input using the Step Function.
        /// </summary>
        /// <param name="passedInput">The Input.</param>
        /// <param name="passedThreshold">The Threshold.</param>
        /// <returns>The Output for the Step Function.</returns>
        public INeuronOutput CalculateOutput(INeuronActivationFunctionInput passedInput, INeuronThreshold passedThreshold)
        {
            float         resultValue = (passedInput.Value >= passedThreshold.Value) ? 1 : 0;
            INeuronOutput result      = new NeuronOutput(resultValue);

            return(result);
        }
예제 #3
0
        // Prints formatted neuron values to console.
        public void ShowNeuron()
        {
            Console.Write("Weights: ");

            foreach (var weight in NeuronWeights)
            {
                Console.Write(weight + " ");
            }

            Console.Write("Output: " + NeuronOutput.ToString());

            Console.Write(" Delta: " + NeuronDelta.ToString());
            Console.WriteLine();
        }
예제 #4
0
        private void AddLayerOutput(int neurons)
        {
            var layer = new LayerOutput
            {
                Neurons = new List <Neuron>(),
            };

            for (var i = 1; i <= neurons; i++)
            {
                var neuron = new NeuronOutput
                {
                    Connections1 = new List <Connection>(),
                    Connections2 = new List <Connection>(),
                };
                neuron.Bias = Math2.Range(-1f, 1);
                layer.Neurons.Add(neuron);
            }
            this.Layers.Add(layer);
        }
예제 #5
0
        /// <summary>
        /// Calculates the Output for the Neuron given the Input.
        /// </summary>
        /// <param name="passedInput">The Input for the Neuron.</param>
        /// <returns>The Output of the Neuron.</returns>
        public INeuronOutput CalculateOutput(INeuronInputs passedInputs)
        {
            float total = 0.0f;

            IEnumerator <INeuronWeight> neuronWeightsEnumerator = this.Weights.Weights;
            IEnumerator <INeuronInput>  neuronInputsEnumerator  = passedInputs.Values;

            while (neuronWeightsEnumerator.MoveNext() && neuronInputsEnumerator.MoveNext())
            {
                INeuronWeight currentWeight = neuronWeightsEnumerator.Current;
                INeuronInput  currentInput  = neuronInputsEnumerator.Current;
                float         tempValue     = currentWeight.Value * currentInput.Value;
                total += tempValue;
            }

            float         computedResult = this.ActivationFunction.CalculateOutput(total, this.Threshold);
            INeuronOutput result         = new NeuronOutput(computedResult);

            return(result);
        }