gpt4 book ai didi

python - 类型错误 : can't pickle PyCapsule objects

转载 作者:太空宇宙 更新时间:2023-11-04 00:06:37 24 4
gpt4 key购买 nike

我使用 dill 将 ML 模型保存到文件。

当我使用 python -m unittest 运行我的测试时,它起作用了。但是,如果我尝试使用 python setup.py test 运行测试,它会在我尝试保存模型的原始格式中出现错误 TypeError: can't pickle PyCapsule objects

我在 setup.py 中的测试设置:

test_suite='测试',
tests_require=['pytest']

错误:

  File "/Users/anna/anaconda3/lib/python3.6/site-packages/dill/_dill.py", line 1055, in save_builtin_method
pickler.save_reduce(_get_attr, (module, obj.__name__), obj=obj)
File "/Users/anna/anaconda3/lib/python3.6/pickle.py", line 610, in save_reduce
save(args)
File "/Users/anna/anaconda3/lib/python3.6/pickle.py", line 476, in save
f(self, obj) # Call unbound method with explicit self
File "/Users/anna/anaconda3/lib/python3.6/pickle.py", line 736, in save_tuple
save(element)
File "/Users/anna/anaconda3/lib/python3.6/pickle.py", line 476, in save
f(self, obj) # Call unbound method with explicit self
File "/Users/anna/anaconda3/lib/python3.6/site-packages/dill/_dill.py", line 1260, in save_module
state=_main_dict)
File "/Users/anna/anaconda3/lib/python3.6/pickle.py", line 634, in save_reduce
save(state)
File "/Users/anna/anaconda3/lib/python3.6/pickle.py", line 476, in save
f(self, obj) # Call unbound method with explicit self
File "/Users/anna/anaconda3/lib/python3.6/site-packages/dill/_dill.py", line 893, in save_module_dict
StockPickler.save_dict(pickler, obj)
File "/Users/anna/anaconda3/lib/python3.6/pickle.py", line 821, in save_dict
self._batch_setitems(obj.items())
File "/Users/anna/anaconda3/lib/python3.6/pickle.py", line 847, in _batch_setitems
save(v)
File "/Users/anna/anaconda3/lib/python3.6/pickle.py", line 496, in save
rv = reduce(self.proto)
TypeError: can't pickle PyCapsule objects

你能帮我知道为什么它不起作用吗?

最佳答案

我是 dill 的作者。这是 dill 的一个已知未决问题。请参阅:https://github.com/uqfoundation/dill/issues/106 .本质上,PyCapsule 对象的序列化函数尚未在 dill 中注册。

更新:截至 https://github.com/uqfoundation/dill/pull/477现在支持 PyCapsule

关于python - 类型错误 : can't pickle PyCapsule objects,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53883328/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com