Applying Saved Neat-python Genome To Test Environment After Training
Solution 1:
I assume that the code you supplied is not your own and that you were following some sort of tutorial. The quality of the code is very low, documentation in form of comments is literally non-existent and variable naming is not english. If you coded that, than that's completely fine for a beginner. Actually even impressive. Though especially for a beginner's tutorial do I highly recommend to search for better explained and documented tutorials.
With that being said, here is the code that you need to add to your project in order to replay a saved genome:
defreplay_genome(config_path, genome_path="winner.pkl"):
# Load requried NEAT config
config = neat.config.Config(neat.DefaultGenome, neat.DefaultReproduction, neat.DefaultSpeciesSet, neat.DefaultStagnation, config_path)
# Unpickle saved winnerwithopen(genome_path, "rb") as f:
genome = pickle.load(f)
# Convert loaded genome into required data structure
genomes = [(1, genome)]
# Call game with only the loaded genome
game(genomes, config)
Obviously as the code quality was quite low was I unable to understand it to such a degree to provide a clean replay code. Therefore the code is simply reusing the existing game code to train the population, though the population consists only of the loaded genome in this case.
Shameless plug: If you want to learn more about Neuroevolution, see here: https://towardsdatascience.com/9068f532f7f7
Post a Comment for "Applying Saved Neat-python Genome To Test Environment After Training"