Examples of EvolutionaryAlgorithm


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

    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

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

  {
    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

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

    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

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();
    } 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

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

   
    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

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

   
    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
Copyright © 2018 www.massapi.com. 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.