pytorch保存模型出错AttributeError: Can‘t pickle local object ‘_initialize.<locals>.patch_forward.<locals>.

AttributeError: Can’t pickle local object ‘_initialize..patch_forward..new_fwd’

也可以参考一篇关于装饰器的
https://gael-varoquaux.info/programming/decoration-in-python-done-right-decorating-and-pickling.html

看了众多资料,我了解到这个问题与装饰器、多进程有关,这个问题主要发生在混合精度训练时,
参考:
保存字典方式
https://blog.csdn.net/weixin_43667077/article/details/108961672
https://blog.csdn.net/qq_43799400/article/details/119151661
更换pickle框架
https://zhuanlan.zhihu.com/p/337239592

你可能感兴趣的:(机器学习,pytorch,python,人工智能)