Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
af7fcb0e
Commit
af7fcb0e
authored
Dec 28, 2012
by
Davis King
Browse files
Improved unit test repeatability.
parent
7087d753
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
6 deletions
+7
-6
dlib/test/svm_c_linear_dcd.cpp
dlib/test/svm_c_linear_dcd.cpp
+7
-6
No files found.
dlib/test/svm_c_linear_dcd.cpp
View file @
af7fcb0e
...
@@ -61,7 +61,7 @@ namespace
...
@@ -61,7 +61,7 @@ namespace
for
(
int
j
=
0
;
j
<
5
;
++
j
)
for
(
int
j
=
0
;
j
<
5
;
++
j
)
{
{
int
idx
=
rnd
.
get_random_32bit_number
()
%
10
;
int
idx
=
rnd
.
get_random_32bit_number
()
%
10
;
double
value
=
static_cast
<
double
>
(
std
::
rand
())
/
RAND_MAX
;
double
value
=
rnd
.
get_random_double
()
;
sample
[
idx
]
=
label
*
value
;
sample
[
idx
]
=
label
*
value
;
}
}
...
@@ -106,7 +106,7 @@ namespace
...
@@ -106,7 +106,7 @@ namespace
svm_c_linear_dcd_trainer
<
kernel_type
>::
optimizer_state
state
;
svm_c_linear_dcd_trainer
<
kernel_type
>::
optimizer_state
state
;
const
double
C
=
0.1
;
const
double
C
=
1.0
;
linear_trainer
.
set_epsilon
(
1e-10
);
linear_trainer
.
set_epsilon
(
1e-10
);
linear_trainer_cpa
.
set_epsilon
(
1e-10
);
linear_trainer_cpa
.
set_epsilon
(
1e-10
);
...
@@ -135,7 +135,7 @@ namespace
...
@@ -135,7 +135,7 @@ namespace
for
(
int
j
=
0
;
j
<
5
;
++
j
)
for
(
int
j
=
0
;
j
<
5
;
++
j
)
{
{
int
idx
=
rnd
.
get_random_32bit_number
()
%
9
;
int
idx
=
rnd
.
get_random_32bit_number
()
%
9
;
double
value
=
static_cast
<
double
>
(
std
::
rand
())
/
RAND_MAX
;
double
value
=
rnd
.
get_random_double
()
;
sample
(
idx
)
=
label
*
value
;
sample
(
idx
)
=
label
*
value
;
}
}
...
@@ -210,7 +210,7 @@ namespace
...
@@ -210,7 +210,7 @@ namespace
for
(
int
j
=
0
;
j
<
5
;
++
j
)
for
(
int
j
=
0
;
j
<
5
;
++
j
)
{
{
int
idx
=
rnd
.
get_random_32bit_number
()
%
10
;
int
idx
=
rnd
.
get_random_32bit_number
()
%
10
;
double
value
=
static_cast
<
double
>
(
std
::
rand
())
/
RAND_MAX
;
double
value
=
rnd
.
get_random_double
()
;
sample
(
idx
)
=
label
*
value
;
sample
(
idx
)
=
label
*
value
;
}
}
...
@@ -244,6 +244,7 @@ namespace
...
@@ -244,6 +244,7 @@ namespace
void
test_normal_force_last_weight
(
bool
have_bias
,
bool
force_weight
)
void
test_normal_force_last_weight
(
bool
have_bias
,
bool
force_weight
)
{
{
typedef
matrix
<
double
,
10
,
1
>
sample_type
;
typedef
matrix
<
double
,
10
,
1
>
sample_type
;
dlog
<<
LINFO
<<
"have_bias: "
<<
have_bias
<<
" force_weight: "
<<
force_weight
;
typedef
linear_kernel
<
sample_type
>
kernel_type
;
typedef
linear_kernel
<
sample_type
>
kernel_type
;
...
@@ -285,7 +286,7 @@ namespace
...
@@ -285,7 +286,7 @@ namespace
for
(
int
j
=
0
;
j
<
5
;
++
j
)
for
(
int
j
=
0
;
j
<
5
;
++
j
)
{
{
int
idx
=
rnd
.
get_random_32bit_number
()
%
9
;
int
idx
=
rnd
.
get_random_32bit_number
()
%
9
;
double
value
=
static_cast
<
double
>
(
std
::
rand
())
/
RAND_MAX
;
double
value
=
rnd
.
get_random_double
()
;
sample
(
idx
)
=
label
*
value
+
label
;
sample
(
idx
)
=
label
*
value
+
label
;
}
}
...
@@ -314,7 +315,7 @@ namespace
...
@@ -314,7 +315,7 @@ namespace
rs
.
add
(
labels
[
k
]
*
df
(
samples
[
k
]));
rs
.
add
(
labels
[
k
]
*
df
(
samples
[
k
]));
}
}
}
}
DLIB_TEST_MSG
(
std
::
abs
(
rs
.
min
()
-
1
)
<
1e-
6
,
std
::
abs
(
rs
.
min
()
-
1
));
DLIB_TEST_MSG
(
std
::
abs
(
rs
.
min
()
-
1
)
<
1e-
7
,
std
::
abs
(
rs
.
min
()
-
1
));
}
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
...
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