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
6d656c61
Commit
6d656c61
authored
Mar 31, 2012
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added some unit tests for the oca object.
parent
fda8545b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
86 additions
and
0 deletions
+86
-0
CMakeLists.txt
dlib/test/CMakeLists.txt
+1
-0
makefile
dlib/test/makefile
+1
-0
oca.cpp
dlib/test/oca.cpp
+84
-0
No files found.
dlib/test/CMakeLists.txt
View file @
6d656c61
...
...
@@ -74,6 +74,7 @@ set (tests
metaprogramming.cpp
multithreaded_object.cpp
object_detector.cpp
oca.cpp
one_vs_all_trainer.cpp
one_vs_one_trainer.cpp
optimization.cpp
...
...
dlib/test/makefile
View file @
6d656c61
...
...
@@ -89,6 +89,7 @@ SRC += member_function_pointer.cpp
SRC
+=
metaprogramming.cpp
SRC
+=
multithreaded_object.cpp
SRC
+=
object_detector.cpp
SRC
+=
oca.cpp
SRC
+=
one_vs_all_trainer.cpp
SRC
+=
one_vs_one_trainer.cpp
SRC
+=
optimization.cpp
...
...
dlib/test/oca.cpp
0 → 100644
View file @
6d656c61
// Copyright (C) 2012 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#include <dlib/optimization.h>
#include <dlib/svm.h>
#include <sstream>
#include <string>
#include <cstdlib>
#include <ctime>
#include <vector>
#include "tester.h"
namespace
{
using
namespace
test
;
using
namespace
dlib
;
using
namespace
std
;
logger
dlog
(
"test.oca"
);
// ----------------------------------------------------------------------------------------
class
test_oca
:
public
tester
{
public
:
test_oca
(
)
:
tester
(
"test_oca"
,
"Runs tests on the oca component."
)
{
}
void
perform_test
(
)
{
print_spinner
();
typedef
matrix
<
double
,
0
,
1
>
w_type
;
w_type
w
;
std
::
vector
<
w_type
>
x
;
w_type
temp
(
2
);
temp
=
-
1
,
1
;
x
.
push_back
(
temp
);
temp
=
1
,
-
1
;
x
.
push_back
(
temp
);
std
::
vector
<
double
>
y
;
y
.
push_back
(
+
1
);
y
.
push_back
(
-
1
);
w_type
true_w
(
3
);
oca
solver
;
// test the version without a non-negativity constraint on w.
solver
(
make_oca_problem_c_svm
<
w_type
>
(
2.0
,
3.0
,
vector_to_matrix
(
x
),
vector_to_matrix
(
y
),
false
,
1e-12
,
40
),
w
,
false
);
dlog
<<
LINFO
<<
w
;
true_w
=
-
0.5
,
0.5
,
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.
solver
(
make_oca_problem_c_svm
<
w_type
>
(
2.0
,
3.0
,
vector_to_matrix
(
x
),
vector_to_matrix
(
y
),
false
,
1e-12
,
40
),
w
,
true
);
dlog
<<
LINFO
<<
w
;
true_w
=
0
,
1
,
0
;
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