Iteration() 공개 메소드

Perform one training iteration.
public Iteration ( ) : void
리턴 void
예제 #1
0
        private void trainNetworkBackprop()
        {
            // IMLTrain train = new Backpropagation(this.network, this.input,this.ideal, 0.000001, 0.1);

            IMLDataSet aset = new BasicMLDataSet(input, ideal);
            int epoch = 1;
            // train the neural network
            ICalculateScore score = new TrainingSetScore(aset);
            IMLTrain trainAlt = new NeuralSimulatedAnnealing(network, score, 10, 2, 100);
            IMLTrain trainMain = new Backpropagation(network, aset, 0.001, 0.0);
            StopTrainingStrategy stop = new StopTrainingStrategy();
            var pop = new NEATPopulation(INPUT_SIZE, OUTPUT_SIZE, 1000);
            // train the neural network
            var step = new ActivationStep();
            step.Center = 0.5;
            pop.OutputActivationFunction = step;
            var train = new NEATTraining(score, pop);
            trainMain.AddStrategy(new Greedy());
            trainMain.AddStrategy(new HybridStrategy(trainAlt));
            trainMain.AddStrategy(stop);
            trainMain.AddStrategy(new HybridStrategy(train));

            network.ClearContext();

            while (!stop.ShouldStop())
            {
                trainMain.Iteration();
                train.Iteration();
                Console.WriteLine(@"Training " + @"Epoch #" + epoch + @" Error:" + trainMain.Error+ @" Genetic iteration:"+trainAlt.IterationNumber+ @"neat iteration:"+train.IterationNumber );
                epoch++;
            }
        }
        private void Validate(NEATPopulation pop)
        {
            Assert.AreEqual(0.3, pop.OldAgePenalty);
            Assert.AreEqual(50, pop.OldAgeThreshold);
            Assert.AreEqual(10, pop.PopulationSize);
            Assert.AreEqual(0.2, pop.SurvivalRate);
            Assert.AreEqual(10, pop.YoungBonusAgeThreshold);
            Assert.AreEqual(0.3, pop.YoungScoreBonus);

            // see if the population can actually be used to train
            IMLDataSet trainingSet = new BasicMLDataSet(XOR.XORInput, XOR.XORIdeal);
            ICalculateScore score = new TrainingSetScore(trainingSet);
            NEATTraining train = new NEATTraining(score, pop);
            train.Iteration();

        }