Need help with NEAT-python

i am trying to use neat python for a simple example like BipedalWalker but the training never starts, instead i only get: ****** Running generation 0 ******

this is the code:

import os
import pickle

import neat
import numpy as np
#import cart_pole
import gymnasium as gym

runs_per_net = 5
# Use the NN network phenotype and the discrete actuator force function.
def eval_genome(genome, config):
net = neat.nn.FeedForwardNetwork.create(genome, config)

fitnesses = []

for runs in range(runs_per_net):
env = gym.make(“BipedalWalker-v3”)

observation,_ = env.reset()
fitness = 0.0
done = False
while not done:

action = net.activate(observation)
observation, reward, done, _,info = env.step(action)
fitness += reward
#env.render()
fitnesses.append(fitness)

return np.mean(fitnesses)

def eval_genomes(genomes, config):
for genome_id, genome in genomes:
genome.fitness = eval_genome(genome, config)

def run():
# Load the config file, which is assumed to live in the same directory as this script.
local_dir = os.path.dirname(__file__)
config_path = os.path.join(local_dir, ‘config.txt’)
config = neat.Config(neat.DefaultGenome, neat.DefaultReproduction,
neat.DefaultSpeciesSet, neat.DefaultStagnation,
config_path)

pop = neat.Population(config)
stats = neat.StatisticsReporter()
pop.add_reporter(stats)
pop.add_reporter(neat.StdOutReporter(True))

# Run NEAT algorithm
winner = pop.run(eval_genomes)

# Save the winner.
with open(‘winner’, ‘wb’) as f:
pickle.dump(winner, f)

print(winner)

run()

i used this tutorial. the config file has only the pop size changed from 250 to 20 but i cant understand why it doesnt train

submitted by /u/SebyR
[link] [comments]

Leave a Reply

The Future Is A.I. !
To top
en_USEnglish