1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 23:33:05 +04:00

Merge pull request #13718 from lochsh:svm-sigmoid-fix

SVM sigmoid kernel fix (issue #13621) (#13718)

* Added test for sigmoid case for retrieving support vectors

* undo unhelpful test

* add test for sigmoid SVM with data that is easily separable into two concentric circles

* Update sigmoid kernel to use tanh(gamma * <x, y> + coef0) instead of -tanh(gamma * <x, y> + coef0)

* remove unnecessary constraint on coef0

* cleanup

* fixing inappropriate use of doubles

* Add f to float literal

* replace CV_Assert with ASSERT_EQ where appropriate
This commit is contained in:
Hannah McLaughlin
2019-01-31 12:34:36 +00:00
committed by Alexander Alekhin
parent 2f5af1bd33
commit 418898029c
2 changed files with 49 additions and 7 deletions
+4 -7
View File
@@ -200,20 +200,19 @@ public:
{
int j;
calc_non_rbf_base( vcount, var_count, vecs, another, results,
-2*params.gamma, -2*params.coef0 );
2*params.gamma, 2*params.coef0 );
// TODO: speedup this
for( j = 0; j < vcount; j++ )
{
Qfloat t = results[j];
Qfloat e = std::exp(-std::abs(t));
Qfloat e = std::exp(std::abs(t));
if( t > 0 )
results[j] = (Qfloat)((1. - e)/(1. + e));
else
results[j] = (Qfloat)((e - 1.)/(e + 1.));
else
results[j] = (Qfloat)((1. - e)/(1. + e));
}
}
void calc_rbf( int vcount, int var_count, const float* vecs,
const float* another, Qfloat* results )
{
@@ -1310,8 +1309,6 @@ public:
if( kernelType != SIGMOID && kernelType != POLY )
params.coef0 = 0;
else if( params.coef0 < 0 )
CV_Error( CV_StsOutOfRange, "The kernel parameter <coef0> must be positive or zero" );
if( kernelType != POLY )
params.degree = 0;