Ejemplo n.º 1
0
def check_add_connection(genome_type, feed_forward):
    local_dir = os.path.dirname(__file__)
    config = Config(os.path.join(local_dir, 'test_configuration'))
    config.input_nodes = 3
    config.output_nodes = 4
    config.hidden_nodes = 5
    config.feedforward = feed_forward
    N = config.input_nodes + config.hidden_nodes + config.output_nodes

    connections = {}
    for a in range(100):
        g = genome_type.create_unconnected(a, config)
        g.add_hidden_nodes(config.hidden_nodes)
        for b in range(1000):
            g.mutate_add_connection()
        for c in g.conn_genes.values():
            connections[c.key] = connections.get(c.key, 0) + 1

    # TODO: The connections should be returned to the caller and checked
    # against the constraints/assumptions particular to the network type.
    for i in range(N):
        values = []
        for j in range(N):
            values.append(connections.get((i, j), 0))
        print("{0:2d}: {1}".format(i, " ".join("{0:3d}".format(x) for x in values)))
Ejemplo n.º 2
0
def test_config_options():
    # sample fitness function
    def eval_fitness(population):
        for individual in population:
            individual.fitness = 1.0

    local_dir = os.path.dirname(__file__)
    config = Config(os.path.join(local_dir, 'test_configuration'))

    for hn in (0, 1, 2):
        config.hidden_nodes = hn
        for fc in (0, 1):
            config.fully_connected = fc
            for act in activation_functions.functions.keys():
                config.allowed_activation = [act]
                for ff in (0, 1):
                    config.feedforward = ff

                    pop = Population(config)
                    pop.run(eval_fitness, 250)
Ejemplo n.º 3
0
def test_config_options():
    # sample fitness function
    def eval_fitness(population):
        for individual in population:
            individual.fitness = 1.0

    local_dir = os.path.dirname(__file__)
    config = Config(os.path.join(local_dir, 'test_configuration'))

    for hn in (0, 1, 2):
        config.hidden_nodes = hn
        for fc in (0, 1):
            config.fully_connected = fc
            for act in activation_functions.functions.keys():
                config.allowed_activation = [act]
                for ff in (0, 1):
                    config.feedforward = ff

                    pop = Population(config)
                    pop.run(eval_fitness, 250)