Beispiel #1
0
        internal void PerformTeaching(double teachingRatio)
        {
            /* We assume that we have non-zero amount of elements in the teaching set,
             * so we don't check if the 0 index is correct. This condition is
             * established by LoadTeachingSet(). */
            if (++_currentElementIndex >= _teachingSet.Count)
            {
                _currentElementIndex = 0;
            }

            _examinedNetwork.LearnSimple(CurrentNormalizedElement, teachingRatio,
                                         ref _previousResponse, ref _previousError);

            _currentResponse =
                _examinedNetwork.Response(CurrentNormalizedElement.Inputs);
            _currentError = new double[_currentResponse.Length];
            for (int i = 0; i < _currentResponse.Length; i++)
            {
                _currentError[i] =
                    CurrentElement.ExpectedOutputs[i] - _currentResponse[i];
            }

            /*double avg = 0.0;
             * foreach (double err in _currentError)
             *  avg += Math.Abs(err);
             * avg /= _currentError.Length;
             * _progressHistory.Buffer.Add((float)avg);*/

            double avg = 0.0;

            foreach (TeachingSet.Element elem in _normalizedTeachingSet)
            {
                double[] resp = _examinedNetwork.Response(elem.Inputs);
                for (int i = 0; i < resp.Length; i++)
                {
                    avg += Math.Abs(elem.ExpectedOutputs[i] - resp[i]);
                }
            }
            avg /= _examinedNetwork.OutputCount * _normalizedTeachingSet.Count;
            _progressHistory.Buffer.Add((float)avg);

            _teachingStep++;
        }
Beispiel #2
0
        private void PerformTeachingCycle()
        {
            MlpNetwork.LearningMethod method =
                uiMethodWidrowHoff.Checked ? MlpNetwork.LearningMethod.WidrowHoff
                : MlpNetwork.LearningMethod.Perceptron;
            int stepCount = (int)uiCycleLength.Value;

            for (int i = 0; i < stepCount; i++)
            {
                int teachingElementIndex            = _randomGenerator.Next(_teachingSet.Count);
                TeachingSet.Element teachingElement =
                    _teachingSet[teachingElementIndex];
                double[] prevResp = null;
                double[] prevErr  = null;

                _examinedNetwork.LearnSimple(teachingElement, 0.1,
                                             ref prevResp, ref prevErr, method);
            }

            StepNumber += stepCount;
            uiChartPlotter.Invalidate();
        }