Exemplo n.º 1
0
        private PerceptronTrainerStepPrediction TrainStepPredict()
        {
            State = PerceptronTrainerState.Training;
            PerceptronTrainerStepPrediction result = new PerceptronTrainerStepPrediction();

            PerceptronTrainerDatapoint CurrentDatapoint = Datapoints[CurrentTrainStep];

            if (CurrentDatapoint.IsPositive)
            {
                result.DataPoint           = CurrentDatapoint.Datapoint;
                result.isPositiveDatapoint = true;
                if (BiasedLearning)
                {
                    return(PredictPositiveBiased(result));
                }
                else
                {
                    return(PredictPositive(result));
                }
            }
            else
            {
                result.DataPoint           = CurrentDatapoint.Datapoint;
                result.isPositiveDatapoint = false;

                if (BiasedLearning)
                {
                    return(PredictNegativeBiased(result));
                }
                else
                {
                    return(PredictNegative(result));
                }
            }
        }
Exemplo n.º 2
0
        public void TrainStep()
        {
            State = PerceptronTrainerState.Training;

            PerceptronTrainerDatapoint CurrentDatapoint = Datapoints[CurrentTrainStep];

            if (CurrentDatapoint.IsPositive)
            {
                if (BiasedLearning)
                {
                    LearnPositiveBiased(CurrentDatapoint.Datapoint);
                }
                else
                {
                    LearnPositive(CurrentDatapoint.Datapoint);
                }
            }
            else
            {
                if (BiasedLearning)
                {
                    LearnNegativeBiased(CurrentDatapoint.Datapoint);
                }
                else
                {
                    LearnNegative(CurrentDatapoint.Datapoint);
                }
            }

            if (CurrentTrainStep >= Datapoints.Count - 1)
            {
                CurrentTrainStep = 0;
                LastPassErrors   = Errors;
                Runs++;
                if (Errors == 0)
                {
                    State       = PerceptronTrainerState.Finished;
                    Convergence = true;
                }
                else
                {
                    Errors = 0;
                }
            }
            else
            {
                CurrentTrainStep++;
            }
        }