当前位置: 首页>>代码示例>>Java>>正文


Java NEATUtil类代码示例

本文整理汇总了Java中org.encog.neural.neat.NEATUtil的典型用法代码示例。如果您正苦于以下问题:Java NEATUtil类的具体用法?Java NEATUtil怎么用?Java NEATUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NEATUtil类属于org.encog.neural.neat包,在下文中一共展示了NEATUtil类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: runEvolvedRace

import org.encog.neural.neat.NEATUtil; //导入依赖的package包/类
private void runEvolvedRace(String nnFile) {
    NEATPopulation population = loadNEAT(nnFile);
    TrainEA trainer = NEATUtil.constructNEATTrainer(population, new DriverFitnessScore());

    NEATNetwork network = (NEATNetwork) trainer.getCODEC().decode(population.getBestGenome());
    NeuralNetworkController nn = new EvolvedController(network);
    DefaultDriverGenome genome = new DefaultDriverGenome(nn);
    DefaultDriver driver = new DefaultDriver();
    driver.loadGenome(genome);

    // start a race
    Race race = new Race();
    race.setTrack("road", "aalborg");
    race.setTermination(Race.Termination.LAPS, 1);
    race.setStage(Controller.Stage.RACE);
    race.addCompetitor(driver);

    race.runWithGUI();
}
 
开发者ID:Ignotus,项目名称:torcsnet,代码行数:20,代码来源:EvolutionaryDriverAlgorithm.java

示例2: main

import org.encog.neural.neat.NEATUtil; //导入依赖的package包/类
public static void main(final String args[]) {

        MLDataSet trainingSet = new BasicMLDataSet(XOR_INPUT, XOR_IDEAL);
        NEATPopulation pop = new NEATPopulation(2,1,1000);
        pop.setInitialConnectionDensity(1.0);// not required, but speeds training
        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);

        Encog.getInstance().shutdown();
    }
 
开发者ID:jeffheaton,项目名称:aifh,代码行数:26,代码来源:NEATXORExample.java

示例3: resetTraining

import org.encog.neural.neat.NEATUtil; //导入依赖的package包/类
public void resetTraining() {
    Substrate substrate = SubstrateFactory.factorSandwichSubstrate(11, 11);
    BoxesScore score = new BoxesScore(11);
    this.pop = new NEATPopulation(substrate, 500);
    this.pop.setActivationCycles(4);
    this.pop.reset();
    this.train = NEATUtil.constructNEATTrainer(this.pop, score);
    OriginalNEATSpeciation speciation = new OriginalNEATSpeciation();
    speciation.setCompatibilityThreshold(1);
    this.train.setSpeciation(speciation = new OriginalNEATSpeciation());
    // train.setThreadCount(1);
}
 
开发者ID:jeffheaton,项目名称:aifh,代码行数:13,代码来源:VisualizeBoxesMain.java

示例4: main

import org.encog.neural.neat.NEATUtil; //导入依赖的package包/类
/**
     * The main method.
     * @param args No arguments are used.
     */
    public static void main(final String args[]) {

//        // create a neural network, without using a factory
//        BasicNetwork network = new BasicNetwork();
//        network.addLayer(new BasicLayer(null,true,2));
//        network.addLayer(new BasicLayer(new ActivationSigmoid(),true,3));
//        network.addLayer(new BasicLayer(new ActivationSigmoid(),false,1));
//        network.getStructure().finalizeStructure();
//        network.reset();
//
//        // create training data
//        MLDataSet trainingSet = new BasicMLDataSet(XOR_INPUT, XOR_IDEAL);
//
//        // train the neural network
//        final ResilientPropagation train = new ResilientPropagation(network, trainingSet);
//
//        int epoch = 1;
//
//        do {
//            train.iteration();
//            System.out.println("Epoch #" + epoch + " Error:" + train.getError());
//            epoch++;
//        } while(train.getError() > 0.01);
//        train.finishTraining();
//
//        // test the neural network
//        System.out.println("Neural Network Results:");
//        for(MLDataPair pair: trainingSet ) {
//            final MLData output = network.compute(pair.getInput());
//            System.out.println(pair.getInput().getData(0) + "," + pair.getInput().getData(1)
//                    + ", actual=" + output.getData(0) + ",ideal=" + pair.getIdeal().getData(0));
//        }
//
//        Encog.getInstance().shutdown();

        MLDataSet trainingSet = new BasicMLDataSet(XOR_INPUT, XOR_IDEAL);
        NEATPopulation pop = new NEATPopulation(2,1,1000);
        pop.setInitialConnectionDensity(1.0);// not required, but speeds training
        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);

        Encog.getInstance().shutdown();

    }
 
开发者ID:robrtj,项目名称:NeuralNetworkImageCompression,代码行数:64,代码来源:XorSample.java


注:本文中的org.encog.neural.neat.NEATUtil类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。