I am trying to use Meanshift from scikit-learn python package in C++. However code works well for the first call,but on second call Python crashes. I use faulthandler
to debug and I got this errors:
Thread 0x00003574 (most recent call first):
Thread 0x00000514 (most recent call first):
File "C:\Python27-X86\lib\site-packages\sklearn\neighbors\base.py", line 258 in _fit
File "C:\Python27-X86\lib\site-packages\sklearn\neighbors\base.py", line 929 in fit
File "C:\Python27-X86\lib\site-packages\sklearn\cluster\mean_shift_.py", line 200 in mean_shift
File "C:\Python27-X86\lib\site-packages\sklearn\cluster\mean_shift_.py", line 425 in fit
Windows exception: code 0x80000004
Code:
MT4_EXPFUNC int __stdcall Levels(double *data, const int arraySize)
{
if (arraySize < 1 || data == NULL) return 2;
double arraySizeInLong = (double)arraySize;
npy_intp npy_arraysize;
npy_arraysize = arraySize;
if (npy_arraysize == NULL) return 4;
PyObject *np_value = PyArray_SimpleNewFromData(1, &npy_arraysize, NPY_DOUBLE, data);
Py_INCREF(np_value);
PyArrayObject* pyArray = (PyArrayObject *)np_value;
Py_INCREF(pyArray);
if (np_value == NULL) return 66;
PyObject *shape = PyTuple_New(2);
PyTuple_SetItem(shape, 0, PyLong_FromDouble(arraySizeInLong));
PyTuple_SetItem(shape, 1, PyLong_FromDouble(1));
Py_INCREF(shape);
PyObject *newArray = PyArray_Reshape(pyArray, shape);
Py_INCREF(newArray);
Py_DECREF(pyArray);
Py_DECREF(shape);
Py_DECREF(np_value);
PyObject *pArgs = PyTuple_New(1);
PyTuple_SetItem(pArgs, 0, newArray);
Py_INCREF(pArgs);
Py_DECREF(newArray);
PyObject *pResult = PyObject_CallObject(MeanShiftFit, pArgs);
Py_DECREF(pArgs);
Py_INCREF(pResult);
Py_DECREF(pResult);
return 1;
}
I'm using Python 2.7.16 X86 and Visual Studio 2015. scikit-learn == 0.20.4
0x80000004 is an exception code specific to data variation on runtime. probably data variant is being interchanged or there is a misvariant in the data you are using.
User contributions licensed under CC BY-SA 3.0