Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Opencv 3.0 SVM crashes for large number of iterations

SVM::Params params;
    params.svmType    = SVM::C_SVC;
    params.kernelType = SVM::LINEAR;
    params.C=options.svm_c;
    params.termCrit.type =TermCriteria::EPS+TermCriteria::MAX_ITER;
    params.termCrit.maxCount =options.svm_iter;
    params.termCrit.epsilon = options.svm_eps;
Ptr<TrainData> svm1;
Ptr<SVM> svm;
svm1= TrainData::create(Tdata2,ROW_SAMPLE,Clbl);     
    svm=ml::SVM::create(params);
svm->train(svm1,0);

This is the simplest example that fails. Works like a charm for almost all of my train data (Tdata2), except some. The error is a "Access violation writing location" error, on line 173 of svm.cpp, which is this piece of code:

 void calc_non_rbf_base( int vcount, int var_count, const float* vecs,
                        const float* another, Qfloat* results,
                        double alpha, double beta )
{
    int j, k;
    for( j = 0; j < vcount; j++ )
    {
        const float* sample = &vecs[j*var_count];
        double s = 0;
        for( k = 0; k <= var_count - 4; k += 4 )
            s += sample[k]*another[k] + sample[k+1]*another[k+1] +
            sample[k+2]*another[k+2] + sample[k+3]*another[k+3];
        for( ; k < var_count; k++ )
            s += sample[k]*another[k];
        results[j] = (Qfloat)(s*alpha + beta); // this is line 173
    }
}

The error can be reproduced with any kind of data, if it is forced to execute for a large number of iterations in order to achieve desired accuracy. However, opencv states nothing anywhere about a "maximum number of iterations".

Note that LibSVM gives me correct results on the same data with same epsilon, but it requires ~8K iterations, which then executes without a problem.

Any ideas on how to solve the problem? It is a very weird problem, since it seems as a bad programming kind of error. As a side-note, i use visual studio 2010 on win7 x64.

Opencv 3.0 SVM crashes for large number of iterations

SVM::Params params;
    params.svmType    = SVM::C_SVC;
    params.kernelType = SVM::LINEAR;
    params.C=options.svm_c;
    params.termCrit.type =TermCriteria::EPS+TermCriteria::MAX_ITER;
    params.termCrit.maxCount =options.svm_iter;
=3000;
    params.termCrit.epsilon = options.svm_eps;
0,001;
Ptr<TrainData> svm1;
Ptr<SVM> svm;
svm1= TrainData::create(Tdata2,ROW_SAMPLE,Clbl);     
    svm=ml::SVM::create(params);
svm->train(svm1,0);

This is the simplest example that fails. Works like a charm for almost all of my train data (Tdata2), except some. The error is a "Access violation writing location" error, on line 173 of svm.cpp, which is this piece of code:

 void calc_non_rbf_base( int vcount, int var_count, const float* vecs,
                        const float* another, Qfloat* results,
                        double alpha, double beta )
{
    int j, k;
    for( j = 0; j < vcount; j++ )
    {
        const float* sample = &vecs[j*var_count];
        double s = 0;
        for( k = 0; k <= var_count - 4; k += 4 )
            s += sample[k]*another[k] + sample[k+1]*another[k+1] +
            sample[k+2]*another[k+2] + sample[k+3]*another[k+3];
        for( ; k < var_count; k++ )
            s += sample[k]*another[k];
        results[j] = (Qfloat)(s*alpha + beta); // this is line 173
    }
}

The error can be reproduced with any kind of data, if it is forced to execute for a large number of iterations in order to achieve desired accuracy. However, opencv states nothing anywhere about a "maximum number of iterations".

Note that LibSVM gives me correct results on the same data with same epsilon, but it requires ~8K iterations, which then executes without a problem.

Any ideas on how to solve the problem? It is a very weird problem, since it seems as a bad programming kind of error. As a side-note, i use visual studio 2010 on win7 x64.

Opencv 3.0 SVM crashes for large number of iterations

SVM::Params params;
    params.svmType    = SVM::C_SVC;
    params.kernelType = SVM::LINEAR;
    params.C=options.svm_c;
    params.termCrit.type =TermCriteria::EPS+TermCriteria::MAX_ITER;
    params.termCrit.maxCount =3000;
    params.termCrit.epsilon = 0,001;
0.001;
Ptr<TrainData> svm1;
Ptr<SVM> svm;
svm1= TrainData::create(Tdata2,ROW_SAMPLE,Clbl);     
    svm=ml::SVM::create(params);
svm->train(svm1,0);

This is the simplest example that fails. Works like a charm for almost all of my train data (Tdata2), except some. The error is a "Access violation writing location" error, on line 173 of svm.cpp, which is this piece of code:

 void calc_non_rbf_base( int vcount, int var_count, const float* vecs,
                        const float* another, Qfloat* results,
                        double alpha, double beta )
{
    int j, k;
    for( j = 0; j < vcount; j++ )
    {
        const float* sample = &vecs[j*var_count];
        double s = 0;
        for( k = 0; k <= var_count - 4; k += 4 )
            s += sample[k]*another[k] + sample[k+1]*another[k+1] +
            sample[k+2]*another[k+2] + sample[k+3]*another[k+3];
        for( ; k < var_count; k++ )
            s += sample[k]*another[k];
        results[j] = (Qfloat)(s*alpha + beta); // this is line 173
    }
}

The error can be reproduced with any kind of data, if it is forced to execute for a large number of iterations in order to achieve desired accuracy. However, opencv states nothing anywhere about a "maximum number of iterations".

Note that LibSVM gives me correct results on the same data with same epsilon, but it requires ~8K iterations, which then executes without a problem.

Any ideas on how to solve the problem? It is a very weird problem, since it seems as a bad programming kind of error. As a side-note, i use visual studio 2010 on win7 x64.

Opencv 3.0 SVM crashes for large number of iterations

SVM::Params params; params.svmType = SVM::C_SVC; params.kernelType = SVM::LINEAR; params.C=options.svm_c; params.termCrit.type =TermCriteria::EPS+TermCriteria::MAX_ITER; params.termCrit.maxCount =3000; params.termCrit.epsilon = 0.001; Ptr<TrainData> Ptr<traindata> svm1; Ptr<SVM> Ptr<svm> svm; svm1= TrainData::create(Tdata2,ROW_SAMPLE,Clbl);
svm=ml::SVM::create(params); svm->train(svm1,0);

svm->train(svm1,0);

This is the simplest example that fails. Works like a charm for almost all of my train data (Tdata2), except some. The error is a "Access violation writing location" error, on line 173 of svm.cpp, which is this piece of code:

 void calc_non_rbf_base( int vcount, int var_count, const float* vecs,
                        const float* another, Qfloat* results,
                        double alpha, double beta )
{
    int j, k;
    for( j = 0; j < vcount; j++ )
    {
        const float* sample = &vecs[j*var_count];
        double s = 0;
        for( k = 0; k <= var_count - 4; k += 4 )
            s += sample[k]*another[k] + sample[k+1]*another[k+1] +
            sample[k+2]*another[k+2] + sample[k+3]*another[k+3];
        for( ; k < var_count; k++ )
            s += sample[k]*another[k];
        results[j] = (Qfloat)(s*alpha + beta); // this is line 173
    }
}

The error can be reproduced with any kind of data, if it is forced to execute for a large number of iterations in order to achieve desired accuracy. However, opencv states nothing anywhere about a "maximum number of iterations".

Note that LibSVM gives me correct results on the same data with same epsilon, but it requires ~8K iterations, which then executes without a problem.

Any ideas on how to solve the problem? It is a very weird problem, since it seems as a bad programming kind of error. As a side-note, i use visual studio 2010 on win7 x64.x64. The labels file is Clbl.jpg and the Tdata2 file is Tdata2.jpg. Don't be alarmed by the .jpg extension, just rename to .xml and they are in the standart format tha opencv is accepting!

Opencv 3.0 SVM crashes for large number of iterations

SVM::Params params; params.svmType = SVM::C_SVC; params.kernelType = SVM::LINEAR; params.C=options.svm_c; params.termCrit.type =TermCriteria::EPS+TermCriteria::MAX_ITER; params.termCrit.maxCount =3000; params.termCrit.epsilon = 0.001; Ptr<traindata> svm1; Ptr<svm> svm; svm1= TrainData::create(Tdata2,ROW_SAMPLE,Clbl);
svm=ml::SVM::create(params); svm->train(svm1,0);

This is the simplest example that fails. Works like a charm for almost all of my train data (Tdata2), except some. The error is a "Access violation writing location" error, on line 173 of svm.cpp, which is this piece of code:

 void calc_non_rbf_base( int vcount, int var_count, const float* vecs,
                        const float* another, Qfloat* results,
                        double alpha, double beta )
{
    int j, k;
    for( j = 0; j < vcount; j++ )
    {
        const float* sample = &vecs[j*var_count];
        double s = 0;
        for( k = 0; k <= var_count - 4; k += 4 )
            s += sample[k]*another[k] + sample[k+1]*another[k+1] +
            sample[k+2]*another[k+2] + sample[k+3]*another[k+3];
        for( ; k < var_count; k++ )
            s += sample[k]*another[k];
        results[j] = (Qfloat)(s*alpha + beta); // this is line 173
    }
}

The error can be reproduced with any kind of data, if it is forced to execute for a large number of iterations in order to achieve desired accuracy. However, opencv states nothing anywhere about a "maximum number of iterations".

Note that LibSVM gives me correct results on the same data with same epsilon, but it requires ~8K iterations, which then executes without a problem.

Any ideas on how to solve the problem? It is a very weird problem, since it seems as a bad programming kind of error. As a side-note, i use visual studio 2010 on win7 x64. The labels file is Clbl.jpg and the Tdata2 file is Tdata2.jpg. Don't be alarmed by the .jpg extension, just Donwload, save as, and rename to .xml and they are in the standart format tha opencv is accepting!

Opencv 3.0 SVM crashes for large number of iterations

SVM::Params params; params.svmType = SVM::C_SVC; params.kernelType = SVM::LINEAR; params.C=options.svm_c; params.termCrit.type =TermCriteria::EPS+TermCriteria::MAX_ITER; params.termCrit.maxCount =3000; params.termCrit.epsilon = 0.001; Ptr<traindata> svm1; Ptr<svm> svm; svm1= TrainData::create(Tdata2,ROW_SAMPLE,Clbl);
svm=ml::SVM::create(params); svm->train(svm1,0);

This is the simplest example that fails. Works like a charm for almost all of my train data (Tdata2), except some. The error is a "Access violation writing location" error, on line 173 of svm.cpp, which is this piece of code:

 void calc_non_rbf_base( int vcount, int var_count, const float* vecs,
                        const float* another, Qfloat* results,
                        double alpha, double beta )
{
    int j, k;
    for( j = 0; j < vcount; j++ )
    {
        const float* sample = &vecs[j*var_count];
        double s = 0;
        for( k = 0; k <= var_count - 4; k += 4 )
            s += sample[k]*another[k] + sample[k+1]*another[k+1] +
            sample[k+2]*another[k+2] + sample[k+3]*another[k+3];
        for( ; k < var_count; k++ )
            s += sample[k]*another[k];
        results[j] = (Qfloat)(s*alpha + beta); // this is line 173
    }
}

The error can be reproduced with any kind of data, if it is forced to execute for a large number of iterations in order to achieve desired accuracy. However, opencv states nothing anywhere about a "maximum number of iterations".

Note that LibSVM gives me correct results on the same data with same epsilon, but it requires ~8K iterations, which then executes without a problem.

Any ideas on how to solve the problem? It is a very weird problem, since it seems as a bad programming kind of error. As a side-note, i use visual studio 2010 on win7 x64. x64 [32gb ram]. The labels file is Clbl.jpg and the Tdata2 file is Tdata2.jpg. Don't be alarmed by the .jpg extension, just Donwload, save as, and rename to .xml and they are in the standart format tha opencv is accepting!accepting! This particular dataset crashes for 2709 iterations on my machine. For 2708 its ok.

Opencv 3.0 SVM crashes for large number of iterations

 SVM::Params params;
     params.svmType    = SVM::C_SVC;
     params.kernelType = SVM::LINEAR;
     params.C=options.svm_c;
     params.termCrit.type =TermCriteria::EPS+TermCriteria::MAX_ITER;
     params.termCrit.maxCount =3000;
     params.termCrit.epsilon = 0.001;
    Ptr<traindata> Ptr<TrainData> svm1;
    Ptr<svm> Ptr<SVM> svm;
 svm1= TrainData::create(Tdata2,ROW_SAMPLE,Clbl); 
svm=ml::SVM::create(params); svm->train(svm1,0);

svm->train(svm1,0);

This is the simplest example that fails. Works like a charm for almost all of my train data (Tdata2), except some. The error is a "Access violation writing location" error, on line 173 of svm.cpp, which is this piece of code:

 void calc_non_rbf_base( int vcount, int var_count, const float* vecs,
                        const float* another, Qfloat* results,
                        double alpha, double beta )
{
    int j, k;
    for( j = 0; j < vcount; j++ )
    {
        const float* sample = &vecs[j*var_count];
        double s = 0;
        for( k = 0; k <= var_count - 4; k += 4 )
            s += sample[k]*another[k] + sample[k+1]*another[k+1] +
            sample[k+2]*another[k+2] + sample[k+3]*another[k+3];
        for( ; k < var_count; k++ )
            s += sample[k]*another[k];
        results[j] = (Qfloat)(s*alpha + beta); // this is line 173
    }
}

The error can be reproduced with any kind of data, if it is forced to execute for a large number of iterations in order to achieve desired accuracy. However, opencv states nothing anywhere about a "maximum number of iterations".

Note that LibSVM gives me correct results on the same data with same epsilon, but it requires ~8K iterations, which then executes without a problem.

Any ideas on how to solve the problem? It is a very weird problem, since it seems as a bad programming kind of error. As a side-note, i use visual studio 2010 on win7 x64 [32gb ram]. The labels file is Clbl.jpg and the Tdata2 file is Tdata2.jpg. Don't be alarmed by the .jpg extension, just Donwload, save as, and rename to .xml and they are in the standart format tha opencv is accepting! This particular dataset crashes for 2709 iterations on my machine. For 2708 its ok.

Opencv 3.0 SVM crashes for large number of iterations

   SVM::Params params;
    params.svmType    = SVM::C_SVC;
    params.kernelType = SVM::LINEAR;
    params.C=options.svm_c;
    params.termCrit.type =TermCriteria::EPS+TermCriteria::MAX_ITER;
    params.termCrit.maxCount =3000;
    params.termCrit.epsilon = 0.001;
Ptr<TrainData> svm1;
Ptr<SVM> svm;
svm1= TrainData::create(Tdata2,ROW_SAMPLE,Clbl);     
    svm=ml::SVM::create(params);
svm->train(svm1,0);

This is the simplest example that fails. Works like a charm for almost all of my train data (Tdata2), except some. The error is a an "Access violation writing location" error, on line 173 of svm.cpp, which is this piece of code:

 void calc_non_rbf_base( int vcount, int var_count, const float* vecs,
                        const float* another, Qfloat* results,
                        double alpha, double beta )
{
    int j, k;
    for( j = 0; j < vcount; j++ )
    {
        const float* sample = &vecs[j*var_count];
        double s = 0;
        for( k = 0; k <= var_count - 4; k += 4 )
            s += sample[k]*another[k] + sample[k+1]*another[k+1] +
            sample[k+2]*another[k+2] + sample[k+3]*another[k+3];
        for( ; k < var_count; k++ )
            s += sample[k]*another[k];
        results[j] = (Qfloat)(s*alpha + beta); // this is line 173
    }
}

The error can be reproduced with any kind of data, if it is forced to execute for a large number of iterations in order to achieve desired accuracy. However, opencv states nothing anywhere about a "maximum number of iterations".

Note that LibSVM gives me correct results on the same data with same epsilon, but it requires ~8K iterations, which then executes without a problem.

Any ideas on how to solve the problem? It is a very weird problem, since it seems as a bad programming kind of error. As a side-note, i use visual studio 2010 on win7 x64 [32gb ram]. The labels file is Clbl.jpg and the Tdata2 file is Tdata2.jpg. Don't be alarmed by the .jpg extension, just Donwload, save as, and rename to .xml and they are in the standart standard format tha that opencv is accepting! This particular dataset crashes for 2709 iterations on my machine. For 2708 its ok.

click to hide/show revision 9
No.9 Revision

updated 2015-02-19 04:54:39 -0500

berak gravatar image

Opencv 3.0 SVM crashes for large number of iterations

 SVM::Params params;
 params.svmType    = SVM::C_SVC;
 params.kernelType = SVM::LINEAR;
 params.C=options.svm_c;
 params.termCrit.type =TermCriteria::EPS+TermCriteria::MAX_ITER;
 params.termCrit.maxCount =3000;
 params.termCrit.epsilon = 0.001;
Ptr<TrainData> svm1;
Ptr<SVM> svm;
svm1= TrainData::create(Tdata2,ROW_SAMPLE,Clbl);     
 svm=ml::SVM::create(params);
 svm->train(svm1,0);

This is the simplest example that fails. Works like a charm for almost all of my train data (Tdata2), except some. The error is an "Access violation writing location" error, on line 173 of svm.cpp, which is this piece of code:

 void calc_non_rbf_base( int vcount, int var_count, const float* vecs,
                        const float* another, Qfloat* results,
                        double alpha, double beta )
{
    int j, k;
    for( j = 0; j < vcount; j++ )
    {
        const float* sample = &vecs[j*var_count];
        double s = 0;
        for( k = 0; k <= var_count - 4; k += 4 )
            s += sample[k]*another[k] + sample[k+1]*another[k+1] +
            sample[k+2]*another[k+2] + sample[k+3]*another[k+3];
        for( ; k < var_count; k++ )
            s += sample[k]*another[k];
        results[j] = (Qfloat)(s*alpha + beta); // this is line 173
    }
}

The error can be reproduced with any kind of data, if it is forced to execute for a large number of iterations in order to achieve desired accuracy. However, opencv states nothing anywhere about a "maximum number of iterations".

Note that LibSVM gives me correct results on the same data with same epsilon, but it requires ~8K iterations, which then executes without a problem.

Any ideas on how to solve the problem? It is a very weird problem, since it seems as a bad programming kind of error. As a side-note, i use visual studio 2010 on win7 x64 [32gb ram]. The labels file is Clbl.jpg and the Tdata2 file is Tdata2.jpg. Don't be alarmed by the .jpg extension, just Donwload, save as, and rename to .xml and they are in the standard format that opencv is accepting! This particular dataset crashes for 2709 iterations on my machine. For 2708 its ok.

Opencv 3.0 SVM crashes for large number of iterations

SVM::Params params;
params.svmType    = SVM::C_SVC;
params.kernelType = SVM::LINEAR;
params.C=options.svm_c;
params.C=10;
params.termCrit.type =TermCriteria::EPS+TermCriteria::MAX_ITER;
params.termCrit.maxCount =3000;
params.termCrit.epsilon = 0.001;
Ptr<TrainData> svm1;
Ptr<SVM> svm;
svm1= TrainData::create(Tdata2,ROW_SAMPLE,Clbl);     
svm=ml::SVM::create(params);
            svm->train(svm1,0);

This is the simplest example that fails. Works like a charm for almost all of my train data (Tdata2), except some. The error is an "Access violation writing location" error, on line 173 of svm.cpp, which is this piece of code:

 void calc_non_rbf_base( int vcount, int var_count, const float* vecs,
                        const float* another, Qfloat* results,
                        double alpha, double beta )
{
    int j, k;
    for( j = 0; j < vcount; j++ )
    {
        const float* sample = &vecs[j*var_count];
        double s = 0;
        for( k = 0; k <= var_count - 4; k += 4 )
            s += sample[k]*another[k] + sample[k+1]*another[k+1] +
            sample[k+2]*another[k+2] + sample[k+3]*another[k+3];
        for( ; k < var_count; k++ )
            s += sample[k]*another[k];
        results[j] = (Qfloat)(s*alpha + beta); // this is line 173
    }
}

The error can be reproduced with any kind of data, if it is forced to execute for a large number of iterations in order to achieve desired accuracy. However, opencv states nothing anywhere about a "maximum number of iterations".

Note that LibSVM gives me correct results on the same data with same epsilon, but it requires ~8K iterations, which then executes without a problem.

Any ideas on how to solve the problem? It is a very weird problem, since it seems as a bad programming kind of error. As a side-note, i use visual studio 2010 on win7 x64 [32gb ram]. The labels file is Clbl.jpg and the Tdata2 file is Tdata2.jpg. Don't be alarmed by the .jpg extension, just Donwload, save as, and rename to .xml and they are in the standard format that opencv is accepting! This particular dataset crashes for 2709 iterations on my machine. For 2708 its ok.

Opencv 3.0 SVM crashes for large number of iterations

SVM::Params params;
params.svmType    = SVM::C_SVC;
params.kernelType = SVM::LINEAR;
params.C=10;
params.termCrit.type =TermCriteria::EPS+TermCriteria::MAX_ITER;
params.termCrit.maxCount =3000;
params.termCrit.epsilon = 0.001;
Ptr<TrainData> svm1;
Ptr<SVM> svm;
svm1= TrainData::create(Tdata2,ROW_SAMPLE,Clbl);     
svm=ml::SVM::create(params);
            svm->train(svm1,0);

This is the simplest example that fails. Works like a charm for almost all of my train data (Tdata2), except some. The error is an "Access violation writing location" error, on line 173 of svm.cpp, which is this piece of code:

 void calc_non_rbf_base( int vcount, int var_count, const float* vecs,
                        const float* another, Qfloat* results,
                        double alpha, double beta )
{
    int j, k;
    for( j = 0; j < vcount; j++ )
    {
        const float* sample = &vecs[j*var_count];
        double s = 0;
        for( k = 0; k <= var_count - 4; k += 4 )
            s += sample[k]*another[k] + sample[k+1]*another[k+1] +
            sample[k+2]*another[k+2] + sample[k+3]*another[k+3];
        for( ; k < var_count; k++ )
            s += sample[k]*another[k];
        results[j] = (Qfloat)(s*alpha + beta); // this is line 173
    }
}

The error can be reproduced with any kind of data, if it is forced to execute for a large number of iterations in order to achieve desired accuracy. However, opencv states nothing anywhere about a "maximum number of iterations".

Note that LibSVM gives me correct results on the same data with same epsilon, but it requires ~8K iterations, which then executes without a problem.

Any ideas on how to solve the problem? It is a very weird problem, since it seems as a bad programming kind of error. As a side-note, i use visual studio 2010 on win7 x64 [32gb ram]. The labels file is Clbl.jpg and the Tdata2 file is Tdata2.jpg. Don't be alarmed by the .jpg extension, just Donwload, save as, and rename to .xml and they are in the standard format that opencv is accepting! This particular dataset crashes for 2709 iterations on my machine. For 2708 its ok.