python pickle object with lambdas

眉间皱痕 提交于 2019-12-10 16:15:55

问题


How can I pickle a python object which contains lambdas?

Can't pickle local object 'BaseDiscretizer.__init__.<locals>.<lambda>'

is the error I get when trying to pickle https://github.com/marcotcr/lime/blob/97a1e2d7c1adf7b0c4f0d3b3e9b15f6197b75c5d/lime/discretize.py when pickling the https://github.com/marcotcr/lime/blob/2703bcdcddd135947fe74e99cc270aa4fac3263a/lime/lime_tabular.py#L88 LimeTabularExplainer


回答1:


The standard pickle module cannot serialize lambdas, but there is a third party package called dill which supports them.



来源:https://stackoverflow.com/questions/45715996/python-pickle-object-with-lambdas

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!