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
a930fe80
Commit
a930fe80
authored
Nov 19, 2017
by
Davis King
Browse files
merged
parents
5d259cd7
c0b7bf9e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
5 deletions
+12
-5
ISSUE_TEMPLATE.md
ISSUE_TEMPLATE.md
+2
-2
dlib/dnn/loss.h
dlib/dnn/loss.h
+10
-3
No files found.
ISSUE_TEMPLATE.md
View file @
a930fe80
...
...
@@ -8,7 +8,7 @@ If you aren't reporting a bug or problem with dlib then delete this template and
<!-- ================================================================ -->
<!-- ========
i
============= BUG REPORT TEMPLATE ===================== -->
<!-- ===================== BUG REPORT TEMPLATE ===================== -->
<!-- ================================================================ -->
...
...
dlib/dnn/loss.h
View file @
a930fe80
...
...
@@ -238,6 +238,13 @@ namespace dlib
};
template
<
typename
T
>
T
safe_log
(
T
input
,
T
epsilon
=
1e-10
)
{
// Prevent trying to calculate the logarithm of a very small number (let alone zero)
return
std
::
log
(
std
::
max
(
input
,
epsilon
));
}
template
<
typename
SUBNET
>
using
loss_binary_log
=
add_loss_layer
<
loss_binary_log_
,
SUBNET
>
;
...
...
@@ -317,7 +324,7 @@ namespace dlib
const
unsigned
long
idx
=
i
*
output_tensor
.
k
()
+
k
;
if
(
k
==
y
)
{
loss
+=
scale
*-
s
td
::
log
(
g
[
idx
]);
loss
+=
scale
*-
s
afe_
log
(
g
[
idx
]);
g
[
idx
]
=
scale
*
(
g
[
idx
]
-
1
);
}
else
...
...
@@ -2139,7 +2146,7 @@ namespace dlib
const
size_t
idx
=
tensor_index
(
output_tensor
,
i
,
k
,
r
,
c
);
if
(
k
==
y
)
{
loss
+=
scale
*-
s
td
::
log
(
g
[
idx
]);
loss
+=
scale
*-
s
afe_
log
(
g
[
idx
]);
g
[
idx
]
=
scale
*
(
g
[
idx
]
-
1
);
}
else
if
(
y
==
label_to_ignore
)
...
...
@@ -2285,7 +2292,7 @@ namespace dlib
const
size_t
idx
=
tensor_index
(
output_tensor
,
i
,
k
,
r
,
c
);
if
(
k
==
y
)
{
loss
+=
weight
*
scale
*-
s
td
::
log
(
g
[
idx
]);
loss
+=
weight
*
scale
*-
s
afe_
log
(
g
[
idx
]);
g
[
idx
]
=
weight
*
scale
*
(
g
[
idx
]
-
1
);
}
else
...
...
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