我有一个用cython
编写的类或扩展类型,就像这样:
cdef class Self_Organized_Map:
cdef
def __cinit__(self,np.ndarray data,.....):
....
我使用
distutils
从这个名为som.pyx
的cython
文件创建了一个Python模块,然后在python
中导入并使用它来创建和训练模型,但是当我想要使用pickle
保存我的模型时,它会给出以下错误:TypeError: can't pickle som.Self_Organized_Map objects
pickle有问题吗?还是我的代码有问题?pickle不能保存扩展对象吗?
__dict__
] (http://cython.readthedocs.io/en/latest/src/reference/extension_types.html#attributes))。一些相关的以前的问题:https://dev59.com/UGcs5IYBdhLWcg3wrmHC https://dev59.com/LJXfa4cB1Zd3GeqPgo6o - DavidW