Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
ba33b82e
Commit
ba33b82e
authored
May 19, 2012
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added some tests to make sure the recent addition to svm_c_linear_trainer
works right.
parent
b7d81290
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
0 deletions
+59
-0
oca.cpp
dlib/test/oca.cpp
+59
-0
No files found.
dlib/test/oca.cpp
View file @
ba33b82e
...
...
@@ -43,6 +43,12 @@ namespace
typedef
matrix
<
double
,
0
,
1
>
w_type
;
w_type
w
;
decision_function
<
linear_kernel
<
w_type
>
>
df
;
svm_c_linear_trainer
<
linear_kernel
<
w_type
>
>
trainer
;
trainer
.
set_c_class1
(
2
);
trainer
.
set_c_class1
(
3
);
trainer
.
set_learns_nonnegative_weights
(
true
);
trainer
.
set_epsilon
(
1e-12
);
std
::
vector
<
w_type
>
x
;
w_type
temp
(
2
);
...
...
@@ -75,6 +81,13 @@ namespace
dlog
<<
LINFO
<<
"error: "
<<
max
(
abs
(
w
-
true_w
));
DLIB_TEST
(
max
(
abs
(
w
-
true_w
))
<
1e-10
);
df
=
trainer
.
train
(
x
,
y
);
w
=
join_cols
(
df
.
basis_vectors
(
0
),
uniform_matrix
<
double
>
(
1
,
1
,
-
df
.
b
));
true_w
=
0
,
1
,
0
;
dlog
<<
LINFO
<<
"error: "
<<
max
(
abs
(
w
-
true_w
));
DLIB_TEST
(
max
(
abs
(
w
-
true_w
))
<
1e-10
);
print_spinner
();
// test the version with a non-negativity constraint on w.
...
...
@@ -132,6 +145,52 @@ namespace
true_w
=
1
,
0
,
0
;
dlog
<<
LINFO
<<
"error: "
<<
max
(
abs
(
w
-
true_w
));
DLIB_TEST
(
max
(
abs
(
w
-
true_w
))
<
1e-10
);
df
=
trainer
.
train
(
x
,
y
);
w
=
join_cols
(
df
.
basis_vectors
(
0
),
uniform_matrix
<
double
>
(
1
,
1
,
-
df
.
b
));
true_w
=
1
,
0
,
0
;
dlog
<<
LINFO
<<
"error: "
<<
max
(
abs
(
w
-
true_w
));
DLIB_TEST
(
max
(
abs
(
w
-
true_w
))
<
1e-10
);
x
.
clear
();
y
.
clear
();
temp
=
-
2
,
2
;
x
.
push_back
(
temp
);
temp
=
0
,
-
0
;
x
.
push_back
(
temp
);
y
.
push_back
(
+
1
);
y
.
push_back
(
-
1
);
trainer
.
set_c
(
10
);
df
=
trainer
.
train
(
x
,
y
);
w
=
join_cols
(
df
.
basis_vectors
(
0
),
uniform_matrix
<
double
>
(
1
,
1
,
-
df
.
b
));
true_w
=
0
,
1
,
-
1
;
dlog
<<
LINFO
<<
"w: "
<<
trans
(
w
);
dlog
<<
LINFO
<<
"error: "
<<
max
(
abs
(
w
-
true_w
));
DLIB_TEST
(
max
(
abs
(
w
-
true_w
))
<
1e-10
);
x
.
clear
();
y
.
clear
();
temp
=
-
2
,
2
;
x
.
push_back
(
temp
);
temp
=
0
,
-
0
;
x
.
push_back
(
temp
);
y
.
push_back
(
-
1
);
y
.
push_back
(
+
1
);
trainer
.
set_c
(
10
);
df
=
trainer
.
train
(
x
,
y
);
w
=
join_cols
(
df
.
basis_vectors
(
0
),
uniform_matrix
<
double
>
(
1
,
1
,
-
df
.
b
));
true_w
=
1
,
0
,
1
;
dlog
<<
LINFO
<<
"w: "
<<
trans
(
w
);
dlog
<<
LINFO
<<
"error: "
<<
max
(
abs
(
w
-
true_w
));
DLIB_TEST
(
max
(
abs
(
w
-
true_w
))
<
1e-10
);
}
}
a
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment