QUVA-Lab / e2cnn

E(2)-Equivariant CNNs Library for Pytorch
https://quva-lab.github.io/e2cnn/
Other
596 stars 75 forks source link

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

Closed EBGU closed 3 years ago

EBGU commented 3 years ago

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 commented 3 years ago

Sorry, I got a typo. It works fine.

Gabri95 commented 3 years ago

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