Exemple #1
0
        public List<double> SlpRunSingle(Sample sample)
        {
            var results = new List<double>();

            foreach (var neuron in Neurons)
            {
                var inputsMultipliedByWeights = sample.Inputs.Zip(neuron.Weights, (i, w) => i * w).Sum();

                var NET = neuron.BonusWeight + inputsMultipliedByWeights;

                results.Add( 1 / (1 + Math.Exp(-NET / Gradient)));
            }

            return results;
        }
Exemple #2
0
        public List<double> SlpTrainSingle(Sample sample, int expectedAnswer)
        {
            var slpResult = SlpRunSingle(sample);
            var errors = new List<double>();

            for (int i = 0; i < Neurons.Count; i++)
            {
                var error = expectedAnswer - slpResult[i];
                errors.Add(error);
                var grad = error / Gradient * slpResult[i] * (1 - slpResult[i]);

                for (int k = 0; k < Neurons[i].Weights.Count; k++)
                {
                    Neurons[i].Weights[k] += LearningCoefficient * sample.Inputs[k] * grad;
                }
                Neurons[i].BonusWeight += LearningCoefficient * grad;
            }
            return errors;
        }