CodeReclaimers / neat-python

Python implementation of the NEAT neuroevolution algorithm
BSD 3-Clause "New" or "Revised" License
1.4k stars 488 forks source link

Help with novelty search #244

Open TheMightiestCarrot opened 2 years ago

TheMightiestCarrot commented 2 years ago

Hey guys,

can someone help me with implementation of novelty serach in neat-python? Or at least explain the novelty serach example? Is this the novelty part?: `

        for a in self.archive:
            adist = np.linalg.norm(float_image.ravel() - a.ravel())
            genome.fitness = min(genome.fitness, adist)

`

Is the implementation problem specific? (distance in Behavior space) Or can it be implemented in more general way by measuring distance of model parameters?

DBraun commented 2 years ago

I think behavior space is the right place for measuring novelty. You could refactor it to choose from many kinds of distance functions.


def L2_distance(a, b):
    return np.linalg.norm(a - b, ord=2)

def L1_distance(a,b):
    return np.linalg.norm(a - b, ord=1)

for a in self.archive:
    adist = L2_distance(float_image.ravel(), a.ravel())
    # adist = L1_distance(float_image.ravel(), a.ravel())
    genome.fitness = min(genome.fitness, adist)

Note that changing a distance function here by plugging it into another monotonic function probably won't have any effect on the training. So L2 will work the same as distance = L2*x+y