Пример #1
0
        public virtual double[] Compute(double[] input, SigmoidFunction function)
        {
            for (int i = 0; i < neurons.Length; i++)
            {
                this.output[i] = neurons[i].Compute(input, function);
            }

            return(output);
        }
Пример #2
0
        public ActivationNetwork(SigmoidFunction function, int inputsCount, params int[] neuronsCount)
        {
            ActivationFunction = function;
            InputsCount        = Math.Max(1, inputsCount);
            Layers             = new ActivationLayer[neuronsCount.Length];

            // create each layer
            for (int i = 0; i < Layers.Length; i++)
            {
                Layers[i] = new ActivationLayer(neuronsCount[i], (i == 0) ? inputsCount : neuronsCount[i - 1]);
            }
        }
Пример #3
0
        public double Compute(double[] input, SigmoidFunction function)
        {
            if (input.Length != inputsCount)
            {
                throw new ArgumentException("Wrong length of the input vector.");
            }

            double sum = 0.0;

            for (int i = 0; i < weights.Length; i++)
            {
                sum += weights[i] * input[i];
            }
            sum += threshold;

            double output = function.Function(sum);

            this.output = output;
            return(output);
        }