cjlin1 / libsvm

LIBSVM -- A Library for Support Vector Machines
https://www.csie.ntu.edu.tw/~cjlin/libsvm/
BSD 3-Clause "New" or "Revised" License
4.55k stars 1.64k forks source link

Exception Thrown: read access violation #204

Closed cloudwsx closed 12 months ago

cloudwsx commented 1 year ago

Hello,

I have a datasets, which Libsvm finsihed fitting. optimization finished, #iter = 23862 nu = 0.869198 obj = -23462.897819, rho = -3.114728 nSV = 22802, nBSV = 22784 But when save the model or predict a test data, it shows "Exception Thrown: read access violation".
It is the "while(p->index != -1)" in svm.cpp file.

if(param.kernel_type == PRECOMPUTED) fprintf(fp,"0:%d ",(int)(p->value)); else while(p->index != -1) { fprintf(fp,"%d:%.8g ",p->index,p->value); p++; } fprintf(fp, "\n");

When I reduced the dataset to less data (for example 10), this issue does not show. I really cannot understand why, can you help give me some hints? Thanks!

Following is the cpp code and datasets. issue.zip

cjlin1 commented 12 months ago

But I don't get the error you reported. On a linux machine I got

libsvm-3.32$ ./main ..................... WARNING: using -h 0 may be faster .. WARNING: using -h 0 may be faster optimization finished, #iter = 23862 nu = 0.869198 obj = -23462.897819, rho = -3.114728 nSV = 22802, nBSV = 22784

and you can see the first several lines of the model file

svm_type epsilon_svr kernel_type linear nr_class 2 total_sv 22802 rho -3.114727682702696 SV -1 1571590813:3.5781446e-204 2:0.35 3:0.65 4:1 1 -1803205701:3.5781446e-204 2:0.225 3:0.5 4:0.533333