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


Python neat.DefaultGenome方法代码示例

本文整理汇总了Python中neat.DefaultGenome方法的典型用法代码示例。如果您正苦于以下问题:Python neat.DefaultGenome方法的具体用法?Python neat.DefaultGenome怎么用?Python neat.DefaultGenome使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在neat的用法示例。


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

示例1: test_fs_neat_no_hidden

# 需要导入模块: import neat [as 别名]
# 或者: from neat import DefaultGenome [as 别名]
def test_fs_neat_no_hidden(self):
        """
        fs_neat with no hidden nodes
        (equivalent to fs_neat_hidden and fs_neat_nohidden with no hidden nodes).
        """
        gid = 42
        config = self.config.genome_config
        config.initial_connection = 'fs_neat'
        config.num_hidden = 0

        g = neat.DefaultGenome(gid)
        self.assertEqual(gid, g.key)
        g.configure_new(config)

        print(g)
        self.assertEqual(set(g.nodes), {0})
        self.assertEqual(len(g.connections), 1) 
开发者ID:CodeReclaimers,项目名称:neat-python,代码行数:19,代码来源:test_genome.py

示例2: test_fs_neat_hidden_old

# 需要导入模块: import neat [as 别名]
# 或者: from neat import DefaultGenome [as 别名]
def test_fs_neat_hidden_old(self):
        """
        fs_neat (without hidden/nohidden specification) with hidden;
        should output warning about doc/code conflict.
        """
        gid = 42
        config = self.config.genome_config
        config.initial_connection = 'fs_neat'
        config.num_hidden = 2

        g = neat.DefaultGenome(gid)
        self.assertEqual(gid, g.key)
        print("\nThis should output a warning:", file=sys.stderr)
        g.configure_new(config)  # TODO: Test for emitted warning

        print(g)
        self.assertEqual(set(g.nodes), {0, 1, 2})
        self.assertEqual(len(g.connections), 1) 
开发者ID:CodeReclaimers,项目名称:neat-python,代码行数:20,代码来源:test_genome.py

示例3: test_fully_connected_no_hidden

# 需要导入模块: import neat [as 别名]
# 或者: from neat import DefaultGenome [as 别名]
def test_fully_connected_no_hidden(self):
        """
        full with no hidden nodes
        (equivalent to full_nodirect and full_direct with no hidden nodes)
        """
        gid = 42
        config = self.config.genome_config
        config.initial_connection = 'full'
        config.num_hidden = 0

        g = neat.DefaultGenome(gid)
        self.assertEqual(gid, g.key)
        g.configure_new(config)

        print(g)
        self.assertEqual(set(g.nodes), {0})
        self.assertEqual(len(g.connections), 2)

        # Check that each input is connected to the output node
        for i in config.input_keys:
            assert ((i, 0) in g.connections) 
开发者ID:CodeReclaimers,项目名称:neat-python,代码行数:23,代码来源:test_genome.py

示例4: test_partially_connected_hidden_nodirect_old

# 需要导入模块: import neat [as 别名]
# 或者: from neat import DefaultGenome [as 别名]
def test_partially_connected_hidden_nodirect_old(self):
        """
        partial (no specification re direct/nodirect) with hidden nodes;
        should output warning re docs/code conflict.
        """
        gid = 42
        config = self.config2.genome_config
        config.initial_connection = 'partial'
        config.connection_fraction = 0.5
        config.num_hidden = 2

        g = neat.DefaultGenome(gid)
        self.assertEqual(gid, g.key)
        print("\nThis should output a warning:", file=sys.stderr)
        g.configure_new(config)  # TODO: Test for emitted warning

        print(g)
        self.assertEqual(set(g.nodes), {0, 1, 2})
        self.assertLess(len(g.connections), 6) 
开发者ID:CodeReclaimers,项目名称:neat-python,代码行数:21,代码来源:test_genome.py

示例5: test_partially_connected_hidden_direct

# 需要导入模块: import neat [as 别名]
# 或者: from neat import DefaultGenome [as 别名]
def test_partially_connected_hidden_direct(self):
        """
        partial with (potential) direct input-output connections
        (and also, potentially, via hidden hodes).
        """
        gid = 42
        config = self.config.genome_config
        config.initial_connection = 'partial_direct'
        config.connection_fraction = 0.5
        config.num_hidden = 2

        g = neat.DefaultGenome(gid)
        self.assertEqual(gid, g.key)
        g.configure_new(config)

        print(g)
        self.assertEqual(set(g.nodes), {0, 1, 2})
        self.assertLess(len(g.connections), 8) 
开发者ID:CodeReclaimers,项目名称:neat-python,代码行数:20,代码来源:test_genome.py

示例6: main

# 需要导入模块: import neat [as 别名]
# 或者: from neat import DefaultGenome [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

示例7: setUp

# 需要导入模块: import neat [as 别名]
# 或者: from neat import DefaultGenome [as 别名]
def setUp(self):
        """
        Determine path to configuration file. This path manipulation is
        here so that the script will run successfully regardless of the
        current working directory.
        """
        local_dir = os.path.dirname(__file__)
        config_path = os.path.join(local_dir, 'test_configuration')
        self.config = neat.Config(neat.DefaultGenome, neat.DefaultReproduction,
                                  neat.DefaultSpeciesSet, neat.DefaultStagnation,
                                  config_path)
        config2_path = os.path.join(local_dir, 'test_configuration2')
        self.config2 = neat.Config(neat.DefaultGenome, neat.DefaultReproduction,
                                   neat.DefaultSpeciesSet, neat.DefaultStagnation,
                                   config2_path) 
开发者ID:CodeReclaimers,项目名称:neat-python,代码行数:17,代码来源:test_genome.py

示例8: test_unconnected_no_hidden

# 需要导入模块: import neat [as 别名]
# 或者: from neat import DefaultGenome [as 别名]
def test_unconnected_no_hidden(self):
        """Unconnected network with only input and output nodes."""
        gid = 42
        config = self.config.genome_config
        config.initial_connection = 'unconnected'
        config.num_hidden = 0

        g = neat.DefaultGenome(gid)
        self.assertEqual(gid, g.key)
        g.configure_new(self.config.genome_config)

        print(g)
        self.assertEqual(set(g.nodes), {0})
        assert (not g.connections) 
开发者ID:CodeReclaimers,项目名称:neat-python,代码行数:16,代码来源:test_genome.py

示例9: test_unconnected_hidden

# 需要导入模块: import neat [as 别名]
# 或者: from neat import DefaultGenome [as 别名]
def test_unconnected_hidden(self):
        """Unconnected network with hidden nodes."""
        gid = 42
        config = self.config.genome_config
        config.initial_connection = 'unconnected'
        config.num_hidden = 2

        g = neat.DefaultGenome(gid)
        self.assertEqual(gid, g.key)
        g.configure_new(self.config.genome_config)

        print(g)
        self.assertEqual(set(g.nodes), {0, 1, 2})
        assert (not g.connections) 
开发者ID:CodeReclaimers,项目名称:neat-python,代码行数:16,代码来源:test_genome.py

示例10: test_fs_neat_hidden

# 需要导入模块: import neat [as 别名]
# 或者: from neat import DefaultGenome [as 别名]
def test_fs_neat_hidden(self):
        """fs_neat with connecting hidden nodes."""
        gid = 42
        config = self.config.genome_config
        config.initial_connection = 'fs_neat_hidden'
        config.num_hidden = 2

        g = neat.DefaultGenome(gid)
        self.assertEqual(gid, g.key)
        g.configure_new(config)

        print(g)
        self.assertEqual(set(g.nodes), {0, 1, 2})
        self.assertEqual(len(g.connections), 3) 
开发者ID:CodeReclaimers,项目名称:neat-python,代码行数:16,代码来源:test_genome.py

示例11: test_fully_connected_hidden_nodirect_old

# 需要导入模块: import neat [as 别名]
# 或者: from neat import DefaultGenome [as 别名]
def test_fully_connected_hidden_nodirect_old(self):
        """
        full (no specification re direct/nodirect) with hidden nodes;
        should output warning re docs/code conflict.
        """
        gid = 42
        config = self.config.genome_config
        config.initial_connection = 'full'
        config.num_hidden = 2

        g = neat.DefaultGenome(gid)
        self.assertEqual(gid, g.key)
        print("\nThis should output a warning:", file=sys.stderr)
        g.configure_new(config)  # TODO: Test for emitted warning

        print(g)
        self.assertEqual(set(g.nodes), {0, 1, 2})
        self.assertEqual(len(g.connections), 6)

        # Check that each input is connected to each hidden node.
        for i in config.input_keys:
            for h in (1, 2):
                assert ((i, h) in g.connections)

        # Check that each hidden node is connected to the output.
        for h in (1, 2):
            assert ((h, 0) in g.connections)

        # Check that inputs are not directly connected to the output
        for i in config.input_keys:
            assert ((i, 0) not in g.connections) 
开发者ID:CodeReclaimers,项目名称:neat-python,代码行数:33,代码来源:test_genome.py

示例12: test_fully_connected_hidden_nodirect

# 需要导入模块: import neat [as 别名]
# 或者: from neat import DefaultGenome [as 别名]
def test_fully_connected_hidden_nodirect(self):
        """full with no direct input-output connections, only via hidden nodes."""
        gid = 42
        config = self.config.genome_config
        config.initial_connection = 'full_nodirect'
        config.num_hidden = 2

        g = neat.DefaultGenome(gid)
        self.assertEqual(gid, g.key)
        g.configure_new(config)

        print(g)
        self.assertEqual(set(g.nodes), {0, 1, 2})
        self.assertEqual(len(g.connections), 6)

        # Check that each input is connected to each hidden node.
        for i in config.input_keys:
            for h in (1, 2):
                assert ((i, h) in g.connections)

        # Check that each hidden node is connected to the output.
        for h in (1, 2):
            assert ((h, 0) in g.connections)

        # Check that inputs are not directly connected to the output
        for i in config.input_keys:
            assert ((i, 0) not in g.connections) 
开发者ID:CodeReclaimers,项目名称:neat-python,代码行数:29,代码来源:test_genome.py

示例13: test_fully_connected_hidden_direct

# 需要导入模块: import neat [as 别名]
# 或者: from neat import DefaultGenome [as 别名]
def test_fully_connected_hidden_direct(self):
        """full with direct input-output connections (and also via hidden hodes)."""
        gid = 42
        config = self.config.genome_config
        config.initial_connection = 'full_direct'
        config.num_hidden = 2

        g = neat.DefaultGenome(gid)
        self.assertEqual(gid, g.key)
        g.configure_new(config)

        print(g)
        self.assertEqual(set(g.nodes), {0, 1, 2})
        self.assertEqual(len(g.connections), 8)

        # Check that each input is connected to each hidden node.
        for i in config.input_keys:
            for h in (1, 2):
                assert ((i, h) in g.connections)

        # Check that each hidden node is connected to the output.
        for h in (1, 2):
            assert ((h, 0) in g.connections)

        # Check that inputs are directly connected to the output
        for i in config.input_keys:
            assert ((i, 0) in g.connections) 
开发者ID:CodeReclaimers,项目名称:neat-python,代码行数:29,代码来源:test_genome.py

示例14: test_partially_connected_hidden_nodirect

# 需要导入模块: import neat [as 别名]
# 或者: from neat import DefaultGenome [as 别名]
def test_partially_connected_hidden_nodirect(self):
        """partial with no direct input-output connections, only via hidden nodes."""
        gid = 42
        config = self.config.genome_config
        config.initial_connection = 'partial_nodirect'
        config.connection_fraction = 0.5
        config.num_hidden = 2

        g = neat.DefaultGenome(gid)
        self.assertEqual(gid, g.key)
        g.configure_new(config)

        print(g)
        self.assertEqual(set(g.nodes), {0, 1, 2})
        self.assertLess(len(g.connections), 6) 
开发者ID:CodeReclaimers,项目名称:neat-python,代码行数:17,代码来源:test_genome.py

示例15: main

# 需要导入模块: import neat [as 别名]
# 或者: from neat import DefaultGenome [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'))
    with open('winner.pkl', 'rb') as f:
        winner = pickle.load(f)
    print('\nBest genome:\n{!s}'.format(winner))
    print('\nOutput:')
    winner_net = neat.nn.FeedForwardNetwork.create(winner, config)
    print('Score:', dino_api.play_game(GetCommand(winner_net))) 
开发者ID:pauloalves86,项目名称:go_dino,代码行数:13,代码来源:play_winner.py


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