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
69a12074
Commit
69a12074
authored
Apr 26, 2016
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
made code faster
parent
47fbaff0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
5 deletions
+11
-5
elastic_net.h
dlib/optimization/elastic_net.h
+11
-5
No files found.
dlib/optimization/elastic_net.h
View file @
69a12074
...
...
@@ -32,14 +32,15 @@ namespace dlib
// rows then we can get rid of them by doing some SVD magic. Doing this doesn't
// make the final results of anything change but makes all the matrices have
// dimensions that are X.nr() in size, which can be much smaller.
matrix
<
double
>
XX
;
XX
=
X_
*
trans
(
X_
);
matrix
<
double
,
0
,
1
>
s
;
svd3
(
trans
(
X_
),
u
,
s
,
eig_vects
);
svd3
(
XX
,
u
,
eig_vals
,
eig_vects
);
s
=
sqrt
(
eig_vals
);
X
=
eig_vects
*
diagm
(
s
);
u
=
trans
(
X_
)
*
tmp
(
eig_vects
*
inv
(
diagm
(
s
)));
// Later on, we will use the eigenvalues of X*trans(X) to compute the solution
// without lasso. So we save them here.
eig_vals
=
squared
(
s
);
samples
.
resize
(
X
.
nr
()
*
2
);
...
...
@@ -103,8 +104,13 @@ namespace dlib
<<
"
\n\t
this: "
<<
this
);
ynorm
=
length_squared
(
Y_
);
Y
=
trans
(
u
)
*
Y_
;
// We can use the ynorm after it has been projected because the only place Y
// appears in the algorithm is in terms of dot products with w and x vectors.
// But those vectors are always in the span of X and therefore we only see the
// part of the norm of Y that is in the span of X (and hence u since u and X
// have the same span by construction)
ynorm
=
length_squared
(
Y
);
xdoty
=
X
*
Y
;
eig_vects_xdoty
=
trans
(
eig_vects
)
*
xdoty
;
...
...
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