Beispiel #1
0
        public void Learn(INeuralNetwork net, ILearningSequence<ISupervisedLearningVector> seq)
        {
            LearningStory = new List<NeuronState>();
            bool isLearned = true;

            do
            {
                StoreState(net);
                isLearned = true;
                IEnumerator<ISupervisedLearningVector> en = seq.Vectors.GetEnumerator();
                while (en.MoveNext())
                {
                    net.SetInput(en.Current.Data);

                    net.Compute();

                    double delta = en.Current.CorrectOutput - net[0];
                    if (delta != 0.0)
                    {
                        isLearned = false;
                        CorrectWeights(net, delta > 0 ? 1.0 : -1.0);
                    }

                }
                seq.Shuffle();

            } while (!isLearned);
            StoreState(net);
        }
Beispiel #2
0
        public void Learn(INeuralNetwork net, ILearningSequence<ISupervisedLearningVector> seq)
        {
            LearningStory = new List<NeuronState>();

            bool isLearned = true;
            int counter = 0;
            do
            {
                StoreState(net);
                isLearned = true;
                IEnumerator<ISupervisedLearningVector> en = seq.Vectors.GetEnumerator();
                while (en.MoveNext())
                {
                    net.SetInput(en.Current.Data);
                    net.Compute();
                    CorrectWeights(net, en.Current.CorrectOutput - net.Layers[1][0].Potential);
                }

                en.Reset();

                while (en.MoveNext())
                {
                    net.SetInput(en.Current.Data);

                    net.Compute();

                    if (Math.Abs(en.Current.CorrectOutput - net[0]) > Epsilon)
                    {
                        isLearned = false;
                        break;
                    }
                }
                seq.Shuffle();
                counter++;
            } while (!isLearned && counter < EpochLimit);
            StoreState(net);
            Failed = !isLearned;
        }