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

AttributeError: Can't pickle local object 'DihedralGroup.irrep.<locals>.<lambda>' #35

Closed
EBGU opened this issue Apr 12, 2021 · 2 comments

Comments

@EBGU
Copy link

EBGU commented Apr 12, 2021

Hi!
I found your package quite helpful! However, when I want to save the model or model.state_dict with torch.save, it failed with the error: AttributeError: Can't pickle local object 'DihedralGroup.irrep..'. I wonder if you have any solution for this? Thank you a lot!

@EBGU
Copy link
Author

EBGU commented Apr 12, 2021

Sorry, I got a typo. It works fine.

@EBGU EBGU closed this as completed Apr 12, 2021
@Gabri95
Copy link
Collaborator

Gabri95 commented Apr 12, 2021

Hey!

I am happy you managed to solve your problem :)

I just wanted to add that I do not expect the models (and most objects generated from the library) to be picklable.
Unfortunately, I made wide use of local functions (e.g. for partial evaluation of their arguments).
However, this kind of objects are not picklable (see https://stackoverflow.com/questions/12019961/python-pickling-nested-functions)

To store the models, instead, you should use model.state_dict() as in PyTorch. That should have no issues

Let me know if you encounter any other problems

best,
Gabriele

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

2 participants