Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model checkpoint issue #9

Closed
arunavo4 opened this issue May 16, 2019 · 1 comment
Closed

Model checkpoint issue #9

arunavo4 opened this issue May 16, 2019 · 1 comment

Comments

@arunavo4
Copy link

I tried to add this line, and there are problems with pickling it seems

pop.add_reporter(neat.Checkpointer(1))

Error:

Saving checkpoint to neat-checkpoint-0
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-53-0f6fae74326a> in <module>()
     54 
     55 if __name__ == "__main__":
---> 56     run(100)

4 frames
<ipython-input-53-0f6fae74326a> in run(n_generations)
     50     pop.add_reporter(neat.Checkpointer(1))
     51 
---> 52     pop.run(eval_genomes, n_generations)
     53 
     54 

/usr/local/lib/python3.6/dist-packages/neat/population.py in run(self, fitness_function, n)
    127             self.species.speciate(self.config, self.population, self.generation)
    128 
--> 129             self.reporters.end_generation(self.config, self.population, self.species)
    130 
    131             self.generation += 1

/usr/local/lib/python3.6/dist-packages/neat/reporting.py in end_generation(self, config, population, species_set)
     34     def end_generation(self, config, population, species_set):
     35         for r in self.reporters:
---> 36             r.end_generation(config, population, species_set)
     37 
     38     def post_evaluate(self, config, population, species, best_genome):

/usr/local/lib/python3.6/dist-packages/neat/checkpoint.py in end_generation(self, config, population, species_set)
     57 
     58         if checkpoint_due:
---> 59             self.save_checkpoint(config, population, species_set, self.current_generation)
     60             self.last_generation_checkpoint = self.current_generation
     61             self.last_time_checkpoint = time.time()

/usr/local/lib/python3.6/dist-packages/neat/checkpoint.py in save_checkpoint(self, config, population, species_set, generation)
     68         with gzip.open(filename, 'w', compresslevel=5) as f:
     69             data = (generation, config, population, species_set, random.getstate())
---> 70             pickle.dump(data, f, protocol=pickle.HIGHEST_PROTOCOL)
     71 
     72     @staticmethod

TypeError: cannot serialize '_io.TextIOWrapper' object
@arunavo4
Copy link
Author

Well I found the solution to this ... Having a logger object attached to the population was causing trouble saving the checkpoint.
Remove the following line and you can now save checkpoints

logger = LogReporter("neat.log", evaluator.eval_genome)
pop.add_reporter(logger)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant