Exemple #1
0
def objective_driven(seed):
    i = seed
    g = NEAT.Genome(0, 6, 0, 4, False, NEAT.ActivationFunction.SIGNED_SIGMOID,
                    NEAT.ActivationFunction.SIGNED_SIGMOID, 0, params)
    pop = NEAT.Population(g, params, True, 1.0, i)
    #pop.RNG.Seed(i)

    generations = 0
    for generation in range(250):
        genome_list = NEAT.GetGenomeList(pop)
        fitness_list = NEAT.EvaluateGenomeList_Serial(genome_list,
                                                      evaluate,
                                                      display=False)
        fitness_list = [k[0] for k in fitness_list]
        NEAT.ZipFitness(genome_list, fitness_list)

        best_fits = [x.GetLeader().GetFitness() for x in pop.Species]
        best = max(best_fits)
        idx = best_fits.index(best)
        print best, pop.Species[idx].GetLeader().GetFitness()
        imgs, res = evaluate(pop.Species[idx].GetLeader(),
                             debug=True,
                             save="gen%d.ply" % generation)

        plt.ion()
        plt.clf()
        subfig = 1
        t_imgs = len(imgs)
        for img in imgs:
            plt.subplot(t_imgs, 1, subfig)
            plt.title("Confidence: %0.2f%%" %
                      (res[subfig - 1, target_class] * 100.0))
            plt.imshow(img)
            subfig += 1
        plt.draw()
        plt.pause(0.1)
        plt.savefig("out%d.png" % generation)
        pop.Epoch()

        generations = generation

    return generations
Exemple #2
0
def objective_driven(seed):
    i = seed
    g = NEAT.Genome(0, 6, 0, 4, False, NEAT.ActivationFunction.SIGNED_SIGMOID, NEAT.ActivationFunction.SIGNED_SIGMOID, 0, params)
    pop = NEAT.Population(g, params, True, 1.0, i)
    #pop.RNG.Seed(i)

    generations = 0
    for generation in range(250):
        genome_list = NEAT.GetGenomeList(pop)
        fitness_list = NEAT.EvaluateGenomeList_Serial(genome_list, evaluate, display=False)
        fitness_list = [k[0] for k in fitness_list]
        NEAT.ZipFitness(genome_list, fitness_list)
        
        best_fits = [x.GetLeader().GetFitness() for x in pop.Species]
        best = max(best_fits)
        idx = best_fits.index(best)
        print best,pop.Species[idx].GetLeader().GetFitness()
        imgs,res = evaluate(pop.Species[idx].GetLeader(),debug=True,save="gen%d.ply"%generation)

        plt.ion()
        plt.clf()
        subfig=1
        t_imgs = len(imgs)
        for img in imgs:
         plt.subplot(t_imgs,1,subfig)
         plt.title("Confidence: %0.2f%%" % (res[subfig-1,target_class]*100.0))
         plt.imshow(img)
         subfig+=1
        plt.draw()
        plt.pause(0.1)
        plt.savefig("out%d.png"%generation)
        pop.Epoch()

        generations = generation

    return generations
Exemple #3
0
        key = sort_list[k][1]
        if key not in niche_transform.include:
            del sort_list[k]
    print "length after purge:", len(sort_list)
    raw_input()

    for k in sort_list[:100]:
        print k, niche_names[k[1]]

    raw_input()

    for _idx in range(0, num_niches):
        idx = sort_list[_idx][1]
        print niche_names[idx], stuff[0][idx]
        imgs, res = evaluate(stuff[1][idx],
                             debug=True,
                             save="out/out%d.ply" % _idx)
        save_render_plot(imgs,
                         str(idx) + " " + niche_names[idx][:30],
                         res_vec=res[:, idx],
                         save="out/out%d.png" % _idx)
    print "done.."
    exit()

rng = NEAT.RNG()


#genome generator
def generator():
    global rng
    g = NEAT.Genome(0, 6, 0, 4, False, NEAT.ActivationFunction.SIGNED_SIGMOID,
Exemple #4
0
 for k in range(len(sort_list)-1,-1,-1):
  key = sort_list[k][1]
  if key not in niche_transform.include:
   del sort_list[k]
 print "length after purge:",len(sort_list)
 raw_input() 

 for k in sort_list[:100]:
  print k,niche_names[k[1]]

 raw_input()

 for _idx in range(0,num_niches):
  idx = sort_list[_idx][1]
  print niche_names[idx],stuff[0][idx]
  imgs,res = evaluate(stuff[1][idx],debug=True,save="out/out%d.ply"%_idx) 
  save_render_plot(imgs,str(idx)+" "+niche_names[idx][:30],res_vec=res[:,idx],save="out/out%d.png"%_idx)
 print "done.."
 exit()

rng=NEAT.RNG()
#genome generator
def generator(): 
     global rng
     g= NEAT.Genome(0, 6, 0, 4, False, NEAT.ActivationFunction.SIGNED_SIGMOID, NEAT.ActivationFunction.SIGNED_SIGMOID, 0, params)
     g.RandomizeParameters(rng)
     return g

def noveltysearch(seed,gens,cpi):
    global rng
    rng.Seed(seed)