Open max3-2 opened 5 years ago
This is also true when pickling any other user class in Python.
Le lun. 31 déc. 2018 11 h 12, max3-2 notifications@github.com a écrit :
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?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/DEAP/deap/issues/323, or mute the thread https://github.com/notifications/unsubscribe-auth/AA6rwmFlEiq1tgOHqThnmS7Jk6rFPpEAks5u-jdxgaJpZM4ZlhcB .
@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?
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.
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