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
2b7b216f
Commit
2b7b216f
authored
Jan 20, 2013
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added more cca() unit tests.
parent
a99fc566
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
0 deletions
+40
-0
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