AlessioGalluccio / FastFlow

an implementation of the architecture of FastFlow (Jiawei Yu et al.)
MIT License
40 stars 13 forks source link

AttributeError: Can't pickle local object '_BaseCouplingBlock.__init__.<locals>.<lambda>' #3

Closed wz940216 closed 2 years ago

wz940216 commented 2 years ago

Error in saving model AttributeError: Can't pickle local object '_BaseCouplingBlock.init..'

in code train.py if c.save_model: model.to('cpu') save_model(model, c.modelname) save_weights(model, c.modelname)

AlessioGalluccio commented 2 years ago

That piece of code comes from https://github.com/marco-rudolph/differnet I haven't modified it yet. Maybe you can find a solution there. Which device did you use?

QQR1 commented 2 years ago

I encountered the same problem when saving the model, the error code is as follows : AttributeError: Can't pickle local object 'AllInOneBlock.__init__.<locals>.<lambda>

AlessioGalluccio commented 2 years ago

Hi @QQR1, @wz940216, I modified the code in train.py from

save_model(model), c.modelname)

to

save_model(model.state_dict(), c.modelname)

I tested it and it should work. Let me know. I found the solution at this link https://github.com/pytorch/pytorch/issues/7545 Best, Alessio