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

Pickling is problematic #323

Open
max3-2 opened this issue Dec 31, 2018 · 3 comments
Open

Pickling is problematic #323

max3-2 opened this issue Dec 31, 2018 · 3 comments

Comments

@max3-2
Copy link

max3-2 commented Dec 31, 2018

When pickling a dict with deap Individuals, unpickling is only possible when the Fitness and the Individuals have been created. This makes using those pickling tedious. This might be a duplicate o f PR#76. Has this been fixed or at least considered?
#280 seems to have already implemented this

@fmder
Copy link
Member

fmder commented Jan 4, 2019 via email

@richban
Copy link

richban commented Jun 5, 2019

@fmder how is possible to solve the pickling issue?

I am storing the best genome following way:

        with open('winner_{0}'.format(hof[0].key), 'wb') as winner:
            pickle.dump(hof[0], winner)

However the unpickling does not work:

genome = pickle.load(f)
AttributeError: Can't get attribute 'Individual' on <module 'deap.creator' from '/Users/richban/.local/share/virtualenvs/behavioral.neuroevolution-ViNSkuNA/lib/python3.7/site-packages/deap/creator.py'>

any suggestions?

@fmder
Copy link
Member

fmder commented Jun 5, 2019

Import the creator from your original script and make sure that class creation is made at the module level.

This is more of a pickling question than a deap question. You can get more information on user class pickling on stack overflow.

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

3 participants