Example #1
0
 def compare_champs(self):
     self.epoch_len = self.hs.hist_full_size - (self.hd + 1)
     r_start = self.epoch_len
     champ_current = open("./champ_data/binance/latest_greatest.pkl", 'rb')
     g = pickle.load(champ_current)
     champ_current.close()
     [cppn] = create_cppn(g, self.config, self.leaf_names, ["cppn_out"])
     net_builder = ESNetwork(self.substrate, cppn, self.params)
     champ_fit = self.evaluate_champ(net_builder, r_start, g, 0)
     for ix, f in enumerate(os.listdir("./champ_data/binance")):
         if (f != "lastest_greatest.pkl"):
             champ_file = open("./champ_data/binance/" + f, 'rb')
             g = pickle.load(champ_file)
             champ_file.close()
             [cppn] = create_cppn(g, self.config, self.leaf_names,
                                  ["cppn_out"])
             net_builder = ESNetwork(self.substrate, cppn, self.params)
             g.fitness = self.evaluate_champ(net_builder,
                                             r_start,
                                             g,
                                             champ_num=ix)
             if (g.fitness > champ_fit):
                 with open("./champ_data/binance/latest_greatest.pkl",
                           'wb') as output:
                     pickle.dump(g, output)
     return
Example #2
0
def make_net(genome, config, bs):
    #start by setting up a substrate for this bad cartpole boi
    params = {
        "initial_depth": 2,
        "max_depth": 4,
        "variance_threshold": 0.8,
        "band_threshold": 0.05,
        "iteration_level": 3,
        "division_threshold": 0.3,
        "max_weight": 34.0,
        "activation": "sigmoid"
    }
    input_cords = []
    output_cords = [(0.0, -1.0, -1.0)]
    sign = 1
    # we will use a 3 dimensional substrate, coords laid out here
    for i in range(4):
        input_cords.append((0.0 - i / 10 * sign, 0.0, 0.0))
        sign *= -1
    leaf_names = []
    for i in range(len(output_cords[0])):
        leaf_names.append(str(i) + "_in")
        leaf_names.append(str(i) + "_out")

    [cppn] = create_cppn(genome, config, leaf_names, ['cppn_out'])
    net_builder = ESNetwork(Substrate(input_cords, output_cords), cppn, params)
    net = net_builder.create_phenotype_network_nd()

    return net
def make_net(genome, config, bs):
    #start by setting up a substrate for this bad cartpole boi
    params = {"initial_depth": 2,
              "max_depth": 4,
              "variance_threshold": 0.00013,
              "band_threshold": 0.00013,
              "iteration_level": 3,
              "division_threshold": 0.00013,
              "max_weight": 3.0,
              "activation": "tanh"}
    input_cords = []
    output_cords = [(0.0, -1.0, 0.0)]
    sign = 1
    for i in range(4):
        input_cords.append((0.0 - i/10*sign, 1.0, 0.0))
        sign *= -1
    leaf_names = []
    for i in range(3):
        leaf_names.append('leaf_one_'+str(i))
        leaf_names.append('leaf_two_'+str(i))

    [cppn] = create_cppn(genome, config, leaf_names, ['cppn_out'])
    # print(cppn)
    print(leaf_names)
    print(config.genome_config.input_keys)
    net_builder = ESNetwork(Substrate(input_cords, output_cords), cppn, params)
    net = net_builder.create_phenotype_network_nd()
    return net
Example #4
0
 def trial_run(self):
     r_start = 0
     file = open("es_trade_god_cppn_3d.pkl", 'rb')
     [cppn] = pickle.load(file)
     network = ESNetwork(self.subStrate, cppn, self.params)
     net = network.create_phenotype_network_nd()
     fitness = self.evaluate(net, network, r_start)
     return fitness
Example #5
0
 def eval_fitness(self, genomes, config):
     self.epoch_len = 16
     r_start = randint(0 + self.epoch_len, self.hs.hist_full_size - self.hd)
     best_g_fit = 0.0
     champ_counter = self.gen_count % 10
     #img_count = 0
     for idx, g in genomes:
         [cppn] = create_cppn(g, config, self.leaf_names, ["cppn_out"])
         net_builder = ESNetwork(self.substrate, cppn, self.params)
         #cppn = neat.nn.FeedForwardNetwork.create(g, config)
         #network = ESNetwork(self.subStrate, cppn, self.params, self.hd)
         #net = network.create_phenotype_network_nd()
         train_ft = self.evaluate(net_builder, r_start, g)
         g.fitness = train_ft
         if (g.fitness > best_g_fit):
             best_g_fit = g.fitness
             with open(
                     "./champ_data/kraken/latest_greatest" +
                     str(champ_counter) + ".pkl", 'wb') as output:
                 pickle.dump(g, output)
         #img_count += 1
     '''
     if(champ_counter == 0):
         self.refresh()
         self.compare_champs()
     '''
     self.gen_count += 1
     return
Example #6
0
 def validate_fitness(self):
     config = self.config
     genomes = neat.Checkpointer.restore_checkpoint("./pkl_pops/pop-checkpoint-27").population
     self.epoch_len = 233
     r_start = self.hs.hist_full_size - self.epoch_len-1
     best_g_fit = 1.0
     for idx in genomes:
         g = genomes[idx]
         cppn = neat.nn.FeedForwardNetwork.create(g, config)
         network = ESNetwork(self.subStrate, cppn, self.params, self.hd)
         net = network.create_phenotype_network_nd()
         g.fitness = self.evaluate(net, network, r_start, g)
         if(g.fitness > best_g_fit):
             best_g_fit = g.fitness
             with open('./champ_data/kraken/latest_greatest.pkl', 'wb') as output:
                 pickle.dump(g, output)
     return
Example #7
0
def make_net(genome,
             config,
             batch_size,
             state_space_dim=111,
             action_space_dim=8) -> RecurrentNet:
    #start by setting up a substrate for this bad ant boi
    params = {
        "initial_depth": 1,
        "max_depth": 5,
        "variance_threshold": 0.8,
        "band_threshold": 0.05,
        "iteration_level": 3,
        "division_threshold": 0.3,
        "max_weight": 10.0,
        "activation": "relu"
    }
    assert params[
        "activation"] in piecewise_linear_activations, f"for NAS without search, network activation needs to be piecewise linear"

    # FIXME this can just be list
    joint_name_dict = {
        0: "hip_4",
        1: "ankle_4",
        2: "hip_1",
        3: "ankle_1",
        4: "hip_2",
        5: "ankle_2",
        6: "hip_3",
        7: "ankle_3",
    }
    assert len(joint_name_dict) == len(output_coords)

    leaf_names = []
    for i in range(len(output_coords[0])):
        leaf_names.append(str(i) + "_in")
        leaf_names.append(str(i) + "_out")
    input_coords = get_in_coords()

    [cppn] = create_cppn(genome, config, leaf_names, ['cppn_out'])
    net_builder = ESNetwork(Substrate(input_coords, output_coords), cppn,
                            params)
    net = net_builder.create_phenotype_network_nd(batch_size=batch_size)
    return net  # RecurrentNet ((not necessarily actually recurrent))
def make_net(genome, config, bs):
    #start by setting up a substrate for this bad cartpole boi
    params = {
        "initial_depth": 1,
        "max_depth": 2,
        "variance_threshold": 0.8,
        "band_threshold": 0.13,
        "iteration_level": 3,
        "division_threshold": 0.3,
        "max_weight": 3.0,
        "activation": "relu"
    }
    input_cords = [(0.1, 0.1, 0.1), (-0.1, -0.1, -0.1)]
    output_cords = [(0.0, 1.0, -1.0), (0.0, 0.0, -1.0), (0.0, -1.0, -1.0)]
    leaf_names = []
    for i in range(len(output_cords[0])):
        leaf_names.append(str(i) + "_in")
        leaf_names.append(str(i) + "_out")

    [cppn] = create_cppn(genome, config, leaf_names, ['cppn_out'])
    net_builder = ESNetwork(Substrate(input_cords, output_cords), cppn, params)
    net = net_builder.create_phenotype_network_nd('./genome_vis')
    return net
def make_net(genome, config, _batch_size):
    params = {
        "initial_depth": 1,
        "max_depth": 2,
        "variance_threshold": 0.8,
        "band_threshold": 0.05,
        "iteration_level": 3,
        "division_threshold": 0.3,
        "max_weight": 30.0,
        "activation": "tanh"
    }
    input_cords = [(-1.0, 1.0, 0.0), (-.5, 1.0, 0.0), (.5, 1.0, 0.0),
                   (1.0, 1.0, 0.0)]
    output_cords = [(-1.0, -1.0, -1.0), (0.0, -1.0, -1.0), (1.0, -1.0, -1.0)]
    leaf_names = []
    for i in range(len(output_cords[0])):
        leaf_names.append(str(i) + "_in")
        leaf_names.append(str(i) + "_out")
    [cppn] = create_cppn(genome, config, leaf_names, ['cppn_out'])
    net_builder = ESNetwork(Substrate(input_cords, output_cords), cppn, params)
    #net = net_builder.create_phenotype_network_nd('./genome_vis')
    return net_builder