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
2b7b216f
Commit
2b7b216f
authored
Jan 20, 2013
by
Davis King
Browse files
Added more cca() unit tests.
parent
a99fc566
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
0 deletions
+40
-0
dlib/test/cca.cpp
dlib/test/cca.cpp
+40
-0
No files found.
dlib/test/cca.cpp
View file @
2b7b216f
...
...
@@ -166,6 +166,16 @@ namespace
DLIB_TEST
(
Ltrans
.
nc
()
==
Rtrans
.
nc
());
dlog
<<
LINFO
<<
"correlations: "
<<
trans
(
correlations
);
if
(
Ltrans
.
nc
()
>
1
)
{
// The CCA projection directions are supposed to be uncorrelated for
// non-matching pairs of projections.
const
double
corr_rot1_error
=
max
(
abs
(
compute_correlations
(
rm_zeros
(
L
*
rotate
<
0
,
1
>
(
Ltrans
)),
rm_zeros
(
R
*
Rtrans
))));
dlog
<<
LINFO
<<
"corr_rot1_error: "
<<
corr_rot1_error
;
DLIB_TEST
(
std
::
abs
(
corr_rot1_error
)
<
1e-11
);
}
// Matching projection directions should be correlated with the amount of
// correlation indicated by the return value of cca().
const
double
corr_error
=
max
(
abs
(
compute_correlations
(
rm_zeros
(
L
*
Ltrans
),
rm_zeros
(
R
*
Rtrans
))
-
correlations
));
dlog
<<
LINFO
<<
"correlation error: "
<<
corr_error
;
DLIB_TEST
(
corr_error
<
1e-13
);
...
...
@@ -175,6 +185,16 @@ namespace
DLIB_TEST
(
Ltrans
.
nc
()
==
Rtrans
.
nc
());
dlog
<<
LINFO
<<
"correlations: "
<<
trans
(
correlations
);
if
(
Ltrans
.
nc
()
>
1
)
{
// The CCA projection directions are supposed to be uncorrelated for
// non-matching pairs of projections.
const
double
corr_rot1_error
=
max
(
abs
(
compute_correlations
(
rm_zeros
(
L
*
rotate
<
0
,
1
>
(
Ltrans
)),
rm_zeros
(
R
*
Rtrans
))));
dlog
<<
LINFO
<<
"corr_rot1_error: "
<<
corr_rot1_error
;
DLIB_TEST
(
std
::
abs
(
corr_rot1_error
)
<
1e-11
);
}
// Matching projection directions should be correlated with the amount of
// correlation indicated by the return value of cca().
const
double
corr_error
=
max
(
abs
(
compute_correlations
(
rm_zeros
(
L
*
Ltrans
),
rm_zeros
(
R
*
Rtrans
))
-
correlations
));
dlog
<<
LINFO
<<
"correlation error: "
<<
corr_error
;
DLIB_TEST
(
corr_error
<
1e-13
);
...
...
@@ -206,6 +226,16 @@ namespace
{
correlations
=
cca
(
L
,
R
,
Ltrans
,
Rtrans
,
rank
);
DLIB_TEST
(
Ltrans
.
nc
()
==
Rtrans
.
nc
());
if
(
Ltrans
.
nc
()
>
1
)
{
// The CCA projection directions are supposed to be uncorrelated for
// non-matching pairs of projections.
const
double
corr_rot1_error
=
max
(
abs
(
compute_correlations
(
rm_zeros
(
L
*
rotate
<
0
,
1
>
(
Ltrans
)),
rm_zeros
(
R
*
Rtrans
))));
dlog
<<
LINFO
<<
"corr_rot1_error: "
<<
corr_rot1_error
;
DLIB_TEST
(
std
::
abs
(
corr_rot1_error
)
<
1e-11
);
}
// Matching projection directions should be correlated with the amount of
// correlation indicated by the return value of cca().
const
double
corr_error
=
max
(
abs
(
compute_correlations
(
rm_zeros
(
L
*
Ltrans
),
rm_zeros
(
R
*
Rtrans
))
-
correlations
));
dlog
<<
LINFO
<<
"correlation error: "
<<
corr_error
;
DLIB_TEST
(
corr_error
<
1e-13
);
...
...
@@ -219,6 +249,16 @@ namespace
{
correlations
=
cca
(
mat_to_sparse
(
L
),
mat_to_sparse
(
R
),
Ltrans
,
Rtrans
,
rank
);
DLIB_TEST
(
Ltrans
.
nc
()
==
Rtrans
.
nc
());
if
(
Ltrans
.
nc
()
>
1
)
{
// The CCA projection directions are supposed to be uncorrelated for
// non-matching pairs of projections.
const
double
corr_rot1_error
=
max
(
abs
(
compute_correlations
(
rm_zeros
(
L
*
rotate
<
0
,
1
>
(
Ltrans
)),
rm_zeros
(
R
*
Rtrans
))));
dlog
<<
LINFO
<<
"corr_rot1_error: "
<<
corr_rot1_error
;
DLIB_TEST
(
std
::
abs
(
corr_rot1_error
)
<
1e-11
);
}
// Matching projection directions should be correlated with the amount of
// correlation indicated by the return value of cca().
const
double
corr_error
=
max
(
abs
(
compute_correlations
(
rm_zeros
(
L
*
Ltrans
),
rm_zeros
(
R
*
Rtrans
))
-
correlations
));
dlog
<<
LINFO
<<
"correlation error: "
<<
corr_error
;
DLIB_TEST
(
corr_error
<
1e-13
);
...
...
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