I train a neat-python model to play snake. I want to save the model after 50 generations, and after that i want to load it and retrain it from there, is it possible? I saw a method where you can replay it, but just replay it one time, not retraining it from that stage.
My code for saving:
winner = p.run(main, 170)
with open("winner.pkl", "wb") as f:
pickle.dump(winner, f)
f.close()
I want to be able to load it and call the run function again to retrain it
def run(config_file):
config = neat.config.Config(neat.DefaultGenome, neat.DefaultReproduction,
neat.DefaultSpeciesSet, neat.DefaultStagnation,
config_file)
p = neat.Population(config)
p.add_reporter(neat.StdOutReporter(True))
stats = neat.StatisticsReporter()
p.add_reporter(stats)
winner = p.run(main, 50)
with open("winner.pkl", "wb") as f:
pickle.dump(winner, f)
f.close()
if __name__ == '__main__':
local_dir = os.path.dirname(__file__)
config_path = os.path.join(local_dir, 'config-feedforward.txt')
run(config_path)