Package org.encog.ml.ea.train

Examples of org.encog.ml.ea.train.EvolutionaryAlgorithm


    pop.reset();

    CalculateScore score = new TrainingSetScore(trainingSet);
    // train the neural network
   
    final EvolutionaryAlgorithm train = NEATUtil.constructNEATTrainer(pop,score);
   
    do {
      train.iteration();
      System.out.println("Epoch #" + train.getIteration() + " Error:" + train.getError()+ ", Species:" + pop.getSpecies().size());
    } while(train.getError() > 0.01);

    NEATNetwork network = (NEATNetwork)train.getCODEC().decode(train.getBestGenome());

    // test the neural network
    System.out.println("Neural Network Results:");
    EncogUtility.evaluate(network, trainingSet);
   
View Full Code Here


   
    // reload the method
    method = null;
   
    if( trainer instanceof EvolutionaryAlgorithm ) {
      EvolutionaryAlgorithm ea = (EvolutionaryAlgorithm)trainer;
      method = ea.getPopulation();
    }
   
    if( method==null ) {
      method = trainer.getMethod()
    }
View Full Code Here

    CalculateScore score = new TrainingSetScore(trainingSet);
    // train the neural network
    ActivationStep step = new ActivationStep();
    step.setCenter(0.5);

    EvolutionaryAlgorithm train = NEATUtil.constructNEATTrainer(
        score, 2, 1, 10);
    //train.setOutputActivationFunction(step);
   
    return (NEATPopulation)train.getPopulation();
  }
View Full Code Here

    Assert.assertEquals(0.2,pop.getSurvivalRate());
   
    // see if the population can actually be used to train
    MLDataSet trainingSet = new BasicMLDataSet(XOR.XOR_INPUT, XOR.XOR_IDEAL);   
    CalculateScore score = new TrainingSetScore(trainingSet);
    EvolutionaryAlgorithm train = NEATUtil.constructNEATTrainer(pop, score);
    train.iteration();

  }
View Full Code Here

    final CalculateScore score = new TrainingSetScore(new BasicMLDataSet(FAKE_DATA, FAKE_DATA));

    // create a new random population and train it
    NEATPopulation pop = new NEATPopulation(FAKE_DATA[0].length, 1, 50);
    pop.reset();
    EvolutionaryAlgorithm training1 = NEATUtil.constructNEATTrainer(pop, score);
    training1.iteration();
    // enough training for now, backup current population to continue later
    final ByteArrayOutputStream serialized1 = new ByteArrayOutputStream();
    new PersistNEATPopulation().save(serialized1, training1.getPopulation());

    // reload initial backup and continue training
    EvolutionaryAlgorithm training2 = NEATUtil.constructNEATTrainer(
      (NEATPopulation)new PersistNEATPopulation().read(new ByteArrayInputStream(serialized1.toByteArray())),
      score);
    training2.iteration();
    // enough training, backup the reloaded population to continue later
    final ByteArrayOutputStream serialized2 = new ByteArrayOutputStream();
    new PersistNEATPopulation().save(serialized2, training2.getPopulation());

    // NEATTraining.init() randomly fails with a NPE in NEATGenome.getCompatibilityScore()
    EvolutionaryAlgorithm training3 = NEATUtil.constructNEATTrainer(
      (NEATPopulation)new PersistNEATPopulation().read(new ByteArrayInputStream(serialized2.toByteArray())),
      score);
    training3.iteration();
    final ByteArrayOutputStream serialized3 = new ByteArrayOutputStream();
    new PersistNEATPopulation().save(serialized3, training3.getPopulation());
  }
View Full Code Here

  {
    final CalculateScore score = new TrainingSetScore(new BasicMLDataSet(FAKE_DATA, FAKE_DATA));
    NEATPopulation pop = new NEATPopulation(FAKE_DATA[0].length, 1, 50);
    pop.reset();
    // create a new random population and train it
    EvolutionaryAlgorithm training1 = NEATUtil.constructNEATTrainer(pop, score);
    training1.iteration();
    // enough training for now, backup current population
    final ByteArrayOutputStream serialized1 = new ByteArrayOutputStream();
    new PersistNEATPopulation().save(serialized1, training1.getPopulation());

    final Population population2 = (Population)new PersistNEATPopulation().read(new ByteArrayInputStream(
      serialized1.toByteArray()));
    final ByteArrayOutputStream serialized2 = new ByteArrayOutputStream();
    new PersistNEATPopulation().save(serialized2, population2);
View Full Code Here

    pop.reset();

    CalculateScore score = new TrainingSetScore(buffer);
    // train the neural network
   
    final EvolutionaryAlgorithm train = NEATUtil.constructNEATTrainer(pop,score);
   
    do {
      train.iteration();
    } while(train.getError() > 0.01 && train.getIteration()<10000);
    Encog.getInstance().shutdown();
    NEATNetwork network = (NEATNetwork)train.getCODEC().decode(train.getBestGenome());
   
    Assert.assertTrue(train.getError()<0.01);
    Assert.assertTrue(network.calculateError(buffer)<0.01);
  }
View Full Code Here

    pop.reset();

    CalculateScore score = new TrainingSetScore(trainingSet);
    // train the neural network
   
    final EvolutionaryAlgorithm train = NEATUtil.constructNEATTrainer(pop,score);
   
    do {
      train.iteration();
    } while(train.getError() > 0.01);

    // test the neural network
    Encog.getInstance().shutdown();
    Assert.assertTrue(train.getError()<0.01);
    NEATNetwork network = (NEATNetwork)train.getCODEC().decode(train.getBestGenome());
    Assert.assertTrue(network.calculateError(trainingSet)<0.01);
  }
View Full Code Here

   
    MLDataSet trainingSet = new BasicMLDataSet(XOR.XOR_INPUT,XOR.XOR_IDEAL);
    NEATPopulation pop = new NEATPopulation(2,1,100);
    pop.reset();
    CalculateScore score = new TrainingSetScore(trainingSet);
    final EvolutionaryAlgorithm train = NEATUtil.constructNEATTrainer(pop,score);
       
    NEATGenome genome1 = new NEATGenome();
    genome1.setAdjustedScore(3.0);
    NEATGenome genome2 = new NEATGenome();
    genome2.setAdjustedScore(2.0);
View Full Code Here

   
    MLDataSet trainingSet = new BasicMLDataSet(XOR.XOR_INPUT,XOR.XOR_IDEAL);
    NEATPopulation pop = new NEATPopulation(2,1,100);
    pop.reset();
    CalculateScore score = new TrainingSetScore(trainingSet);
    final EvolutionaryAlgorithm train = NEATUtil.constructNEATTrainer(pop,score);
       
    NEATGenome genome1 = new NEATGenome();
    genome1.setAdjustedScore(3.0);
    NEATGenome genome2 = new NEATGenome();
    genome2.setAdjustedScore(2.0);
View Full Code Here

TOP

Related Classes of org.encog.ml.ea.train.EvolutionaryAlgorithm

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.