當前位置: 首頁>>代碼示例>>Python>>正文


Python neat.DefaultSpeciesSet方法代碼示例

本文整理匯總了Python中neat.DefaultSpeciesSet方法的典型用法代碼示例。如果您正苦於以下問題:Python neat.DefaultSpeciesSet方法的具體用法?Python neat.DefaultSpeciesSet怎麽用?Python neat.DefaultSpeciesSet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在neat的用法示例。


在下文中一共展示了neat.DefaultSpeciesSet方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_valid_fitness_criterion

# 需要導入模塊: import neat [as 別名]
# 或者: from neat import DefaultSpeciesSet [as 別名]
def test_valid_fitness_criterion(self):
        for c in ('max', 'min', 'mean'):
            # Load configuration.
            local_dir = os.path.dirname(__file__)
            config_path = os.path.join(local_dir, 'test_configuration')
            config = neat.Config(neat.DefaultGenome, neat.DefaultReproduction,
                                 neat.DefaultSpeciesSet, neat.DefaultStagnation,
                                 config_path)
            config.fitness_criterion = c

            p = neat.Population(config)

            def eval_genomes(genomes, config):
                for genome_id, genome in genomes:
                    genome.fitness = 1.0

            p.run(eval_genomes, 10) 
開發者ID:CodeReclaimers,項目名稱:neat-python,代碼行數:19,代碼來源:test_population.py

示例2: test_bad_config_unknown_option

# 需要導入模塊: import neat [as 別名]
# 或者: from neat import DefaultSpeciesSet [as 別名]
def test_bad_config_unknown_option():
    """Check that an unknown option (at least in some sections) raises an exception."""
    local_dir = os.path.dirname(__file__)
    config_path = os.path.join(local_dir, 'bad_configuration2')
    try:
        config = neat.Config(neat.DefaultGenome, neat.DefaultReproduction,
                             neat.DefaultSpeciesSet, neat.DefaultStagnation,
                             config_path)
    except NameError:
        pass
    else:
        raise Exception("Did not get a NameError from an unknown configuration file option (in the 'DefaultSpeciesSet' section)")
    config3_path = os.path.join(local_dir, 'bad_configuration3')
    try:
        config = neat.Config(neat.DefaultGenome, neat.DefaultReproduction,
                             neat.DefaultSpeciesSet, neat.DefaultStagnation,
                             config3_path)
    except NameError:
        pass
    else:
        raise Exception("Did not get a NameError from an unknown configuration file option (in the 'NEAT' section)") 
開發者ID:CodeReclaimers,項目名稱:neat-python,代碼行數:23,代碼來源:test_config.py

示例3: test_serial_bad_input

# 需要導入模塊: import neat [as 別名]
# 或者: from neat import DefaultSpeciesSet [as 別名]
def test_serial_bad_input():
    """Make sure get error for bad input."""
    # Load configuration.
    local_dir = os.path.dirname(__file__)
    config_path = os.path.join(local_dir, 'test_configuration')
    config = neat.Config(neat.DefaultGenome, neat.DefaultReproduction,
                         neat.DefaultSpeciesSet, neat.DefaultStagnation,
                         config_path)

    # Create the population, which is the top-level object for a NEAT run.
    p = neat.Population(config)

    try:
        p.run(eval_dummy_genomes_nn_bad, 45)
    except Exception:  # may change in nn.feed_forward code to more specific...
        pass
    else:
        raise Exception("Did not get Exception from bad input") 
開發者ID:CodeReclaimers,項目名稱:neat-python,代碼行數:20,代碼來源:test_simple_run.py

示例4: test_serial4_bad

# 需要導入模塊: import neat [as 別名]
# 或者: from neat import DefaultSpeciesSet [as 別名]
def test_serial4_bad():
    """Make sure no_fitness_termination and n=None give an error."""
    # Load configuration.
    local_dir = os.path.dirname(__file__)
    config_path = os.path.join(local_dir, 'test_configuration4')
    config = neat.Config(neat.DefaultGenome, neat.DefaultReproduction,
                         neat.DefaultSpeciesSet, neat.DefaultStagnation,
                         config_path)

    if VERBOSE:
        print("config.genome_config.__dict__: {!r}".format(
            config.genome_config.__dict__))

    # Create the population, which is the top-level object for a NEAT run.
    p = neat.Population(config)

    try:
        p.run(eval_dummy_genomes_nn, None)
    except RuntimeError:
        pass
    else:
        raise Exception(
            "Should have had a RuntimeError with n=None and no_fitness_termination") 
開發者ID:CodeReclaimers,項目名稱:neat-python,代碼行數:25,代碼來源:test_simple_run.py

示例5: test_serial_bad_config

# 需要導入模塊: import neat [as 別名]
# 或者: from neat import DefaultSpeciesSet [as 別名]
def test_serial_bad_config():
    """Test if bad_configuration1 causes a LookupError or TypeError on trying to run."""
    # Load configuration.
    local_dir = os.path.dirname(__file__)
    config_path = os.path.join(local_dir, 'bad_configuration1')
    config = neat.Config(neat.DefaultGenome, neat.DefaultReproduction,
                         neat.DefaultSpeciesSet, neat.DefaultStagnation,
                         config_path)

    # Create the population, which is the top-level object for a NEAT run.
    p = neat.Population(config)

    try:
        p.run(eval_dummy_genomes_nn, 19)
    except (LookupError, TypeError):
        pass
    else:
        raise Exception(
            "Should have had a LookupError/TypeError with bad_configuration1") 
開發者ID:CodeReclaimers,項目名稱:neat-python,代碼行數:21,代碼來源:test_simple_run.py

示例6: test_serial_extinction_exception

# 需要導入模塊: import neat [as 別名]
# 或者: from neat import DefaultSpeciesSet [as 別名]
def test_serial_extinction_exception():
    """Test for complete extinction with exception."""
    # Load configuration.
    local_dir = os.path.dirname(__file__)
    config_path = os.path.join(local_dir, 'test_configuration')
    config = neat.Config(neat.DefaultGenome, neat.DefaultReproduction,
                         neat.DefaultSpeciesSet, neat.DefaultStagnation,
                         config_path)
    config.stagnation_config.max_stagnation = 1
    config.stagnation_config.species_elitism = 0

    # Create the population, which is the top-level object for a NEAT run.
    p = neat.Population(config)

    # Add a stdout reporter to show progress in the terminal.
    p.add_reporter(neat.StdOutReporter(True))

    try:
        # Run for up to 45 generations.
        p.run(eval_dummy_genomes_nn, 45)
    except Exception:
        pass
    else:
        raise Exception("Should have had a complete extinction at some point!") 
開發者ID:CodeReclaimers,項目名稱:neat-python,代碼行數:26,代碼來源:test_simple_run.py

示例7: test_parallel

# 需要導入模塊: import neat [as 別名]
# 或者: from neat import DefaultSpeciesSet [as 別名]
def test_parallel():
    """Test parallel run using ParallelEvaluator (subprocesses)."""
    # Load configuration.
    local_dir = os.path.dirname(__file__)
    config_path = os.path.join(local_dir, 'test_configuration')
    config = neat.Config(neat.DefaultGenome, neat.DefaultReproduction,
                         neat.DefaultSpeciesSet, neat.DefaultStagnation,
                         config_path)

    # Create the population, which is the top-level object for a NEAT run.
    p = neat.Population(config)

    # Add a stdout reporter to show progress in the terminal.
    p.add_reporter(neat.StdOutReporter(VERBOSE))
    stats = neat.StatisticsReporter()
    p.add_reporter(stats)
    p.add_reporter(neat.Checkpointer(1, 5))

    # Run for up to 19 generations.
    pe = neat.ParallelEvaluator(1 + multiprocessing.cpu_count(), eval_dummy_genome_nn)
    p.run(pe.evaluate, 19)

    stats.save() 
開發者ID:CodeReclaimers,項目名稱:neat-python,代碼行數:25,代碼來源:test_simple_run.py

示例8: test_threaded_evaluation

# 需要導入模塊: import neat [as 別名]
# 或者: from neat import DefaultSpeciesSet [as 別名]
def test_threaded_evaluation():
    """Tests a neat evolution using neat.threaded.ThreadedEvaluator"""
    # Load configuration.
    local_dir = os.path.dirname(__file__)
    config_path = os.path.join(local_dir, 'test_configuration')
    config = neat.Config(neat.DefaultGenome, neat.DefaultReproduction,
                         neat.DefaultSpeciesSet, neat.DefaultStagnation,
                         config_path)

    # Create the population, which is the top-level object for a NEAT run.
    p = neat.Population(config)

    # Add a stdout reporter to show progress in the terminal.
    p.add_reporter(neat.StdOutReporter(True))
    stats = neat.StatisticsReporter()
    p.add_reporter(stats)
    p.add_reporter(neat.Checkpointer(1, 5))

    # Run for up to 19 generations.
    pe = neat.ThreadedEvaluator(4, eval_dummy_genome_nn)
    p.run(pe.evaluate, 19)

    stats.save() 
開發者ID:CodeReclaimers,項目名稱:neat-python,代碼行數:25,代碼來源:test_simple_run.py

示例9: test_run_nn_recurrent

# 需要導入模塊: import neat [as 別名]
# 或者: from neat import DefaultSpeciesSet [as 別名]
def test_run_nn_recurrent():
    """Basic test of nn.recurrent function."""
    # Load configuration.
    local_dir = os.path.dirname(__file__)
    config_path = os.path.join(local_dir, 'test_configuration')
    config = neat.Config(neat.DefaultGenome, neat.DefaultReproduction,
                         neat.DefaultSpeciesSet, neat.DefaultStagnation,
                         config_path)
    config.feed_forward = False

    # Create the population, which is the top-level object for a NEAT run.
    p = neat.Population(config)

    # Add a stdout reporter to show progress in the terminal.
    p.add_reporter(neat.StdOutReporter(VERBOSE))
    stats = neat.StatisticsReporter()
    p.add_reporter(stats)
    p.add_reporter(neat.Checkpointer(1, 5))

    # Run for up to 19 generations.
    p.run(eval_dummy_genomes_nn_recurrent, 19)

    stats.save() 
開發者ID:CodeReclaimers,項目名稱:neat-python,代碼行數:25,代碼來源:test_simple_run.py

示例10: test_run_ctrnn_bad

# 需要導入模塊: import neat [as 別名]
# 或者: from neat import DefaultSpeciesSet [as 別名]
def test_run_ctrnn_bad():
    """Make sure ctrnn gives error on bad input."""
    # Load configuration.
    local_dir = os.path.dirname(__file__)
    config_path = os.path.join(local_dir, 'test_configuration')
    config = neat.Config(neat.DefaultGenome, neat.DefaultReproduction,
                         neat.DefaultSpeciesSet, neat.DefaultStagnation,
                         config_path)
    config.feed_forward = False

    # Create the population, which is the top-level object for a NEAT run.
    p = neat.Population(config)

    try:
        p.run(eval_dummy_genomes_ctrnn_bad, 19)
    except RuntimeError:
        pass
    else:
        raise Exception("Did not get RuntimeError for bad input to ctrnn") 
開發者ID:CodeReclaimers,項目名稱:neat-python,代碼行數:21,代碼來源:test_simple_run.py

示例11: test_run_iznn_bad

# 需要導入模塊: import neat [as 別名]
# 或者: from neat import DefaultSpeciesSet [as 別名]
def test_run_iznn_bad():
    """Make sure iznn gives error on bad input."""
    # Load configuration.
    local_dir = os.path.dirname(__file__)
    config_path = os.path.join(local_dir, 'test_configuration_iznn')
    config = neat.Config(neat.iznn.IZGenome, neat.DefaultReproduction,
                         neat.DefaultSpeciesSet, neat.DefaultStagnation,
                         config_path)

    # Create the population, which is the top-level object for a NEAT run.
    p = neat.Population(config)

    try:
        p.run(eval_dummy_genomes_iznn_bad, 19)
    except RuntimeError:
        pass
    else:
        raise Exception("Did not get RuntimeError for bad input to iznn") 
開發者ID:CodeReclaimers,項目名稱:neat-python,代碼行數:20,代碼來源:test_simple_run.py

示例12: _run

# 需要導入模塊: import neat [as 別名]
# 或者: from neat import DefaultSpeciesSet [as 別名]
def _run(self, config_file, n):
        config = neat.Config(neat.DefaultGenome, neat.DefaultReproduction,
                             neat.DefaultSpeciesSet, neat.DefaultStagnation,
                             config_file)
        # p = neat.Population(config)
        p = neat.Checkpointer.restore_checkpoint(self.file_name)
        p.add_reporter(neat.StdOutReporter(True))
        p.add_reporter(neat.Checkpointer(5))
        stats = neat.StatisticsReporter()
        p.add_reporter(stats)
        print("loaded checkpoint...")
        winner = p.run(self._eval_genomes, n)
        win = p.best_genome
        pickle.dump(winner, open('winner.pkl', 'wb'))
        pickle.dump(win, open('real_winner.pkl', 'wb'))

        visualize.draw_net(config, winner, True)
        visualize.plot_stats(stats, ylog=False, view=True)
        visualize.plot_species(stats, view=True) 
開發者ID:vivek3141,項目名稱:super-mario-neat,代碼行數:21,代碼來源:cont_train.py

示例13: _run

# 需要導入模塊: import neat [as 別名]
# 或者: from neat import DefaultSpeciesSet [as 別名]
def _run(self, config_file, n):
        config = neat.Config(neat.DefaultGenome, neat.DefaultReproduction,
                             neat.DefaultSpeciesSet, neat.DefaultStagnation,
                             config_file)
        p = neat.Population(config)
        p.add_reporter(neat.StdOutReporter(True))
        p.add_reporter(neat.Checkpointer(5))
        stats = neat.StatisticsReporter()
        p.add_reporter(stats)
        print("loaded checkpoint...")
        winner = p.run(self._eval_genomes, n)
        win = p.best_genome
        pickle.dump(winner, open('winner.pkl', 'wb'))
        pickle.dump(win, open('real_winner.pkl', 'wb'))

        visualize.draw_net(config, winner, True)
        visualize.plot_stats(stats, ylog=False, view=True)
        visualize.plot_species(stats, view=True) 
開發者ID:vivek3141,項目名稱:super-mario-neat,代碼行數:20,代碼來源:train.py

示例14: main

# 需要導入模塊: import neat [as 別名]
# 或者: from neat import DefaultSpeciesSet [as 別名]
def main():
    local_dir = os.path.dirname(__file__)
    config = Config(neat.DefaultGenome, neat.DefaultReproduction,
                    neat.DefaultSpeciesSet, neat.DefaultStagnation,
                    os.path.join(local_dir, 'train_config.txt'))
    config.save_best = True
    config.checkpoint_time_interval = 3

    pop = population.Population(config)
    stats = neat.StatisticsReporter()
    pop.add_reporter(stats)
    pop.add_reporter(neat.StdOutReporter(True))
    pop.add_reporter(neat.StatisticsReporter())
    pop.add_reporter(neat.Checkpointer(2))
    winner = pop.run(eval_fitness, 100)
    with open('winner.pkl', 'wb') as f:
        pickle.dump(winner, f) 
開發者ID:pauloalves86,項目名稱:go_dino,代碼行數:19,代碼來源:trainer.py

示例15: run

# 需要導入模塊: import neat [as 別名]
# 或者: from neat import DefaultSpeciesSet [as 別名]
def run():
    config = neat.Config(neat.DefaultGenome, neat.DefaultReproduction,
                         neat.DefaultSpeciesSet, neat.DefaultStagnation, CONFIG)
    pop = neat.Population(config)

    # recode history
    stats = neat.StatisticsReporter()
    pop.add_reporter(stats)
    pop.add_reporter(neat.StdOutReporter(True))
    pop.add_reporter(neat.Checkpointer(5))

    pop.run(eval_genomes, 10)       # train 10 generations

    # visualize training
    visualize.plot_stats(stats, ylog=False, view=True)
    visualize.plot_species(stats, view=True) 
開發者ID:MorvanZhou,項目名稱:Evolutionary-Algorithm,代碼行數:18,代碼來源:run_cartpole.py


注:本文中的neat.DefaultSpeciesSet方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。