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
e89d468b
Commit
e89d468b
authored
Nov 20, 2015
by
Davis King
Browse files
Added log1pexp()
parent
5e92f10f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
0 deletions
+27
-0
dlib/dnn/core.h
dlib/dnn/core.h
+18
-0
dlib/dnn/core_abstract.h
dlib/dnn/core_abstract.h
+9
-0
No files found.
dlib/dnn/core.h
View file @
e89d468b
...
...
@@ -14,11 +14,29 @@
#include "../algs.h"
#include <utility>
#include <tuple>
#include <cmath>
namespace
dlib
{
// ----------------------------------------------------------------------------------------
inline
double
log1pexp
(
double
x
)
{
using
std
::
exp
;
using
namespace
std
;
// Do this instead of using std::log1p because some compilers
// error out otherwise (E.g. gcc 4.9 in cygwin)
if
(
x
<=
-
37
)
return
exp
(
x
);
else
if
(
-
37
<
x
&&
x
<=
18
)
return
log1p
(
exp
(
x
));
else
if
(
18
<
x
&&
x
<=
33.3
)
return
x
+
exp
(
-
x
);
else
return
x
;
}
// ----------------------------------------------------------------------------------------
// Tell us if T is one of the special layer types (i.e. add_layer, add_tag_layer, or
...
...
dlib/dnn/core_abstract.h
View file @
e89d468b
...
...
@@ -45,6 +45,15 @@ namespace dlib
So it basically returns make_tuple(get<1>(item),get<2>(item),get<3>(item), and so on).
!*/
double
log1pexp
(
double
x
);
/*!
ensures
- returns log(1+exp(x))
(except computes it using a numerically accurate method)
!*/
// ----------------------------------------------------------------------------------------
template
<
...
...
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