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
a930fe80
Commit
a930fe80
authored
Nov 19, 2017
by
Davis King
Browse files
Options
Browse Files
Download
Plain Diff
merged
parents
5d259cd7
c0b7bf9e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
4 deletions
+11
-4
ISSUE_TEMPLATE.md
ISSUE_TEMPLATE.md
+1
-1
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
...
@@ -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
...
@@ -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
>
template
<
typename
SUBNET
>
using
loss_binary_log
=
add_loss_layer
<
loss_binary_log_
,
SUBNET
>
;
using
loss_binary_log
=
add_loss_layer
<
loss_binary_log_
,
SUBNET
>
;
...
@@ -317,7 +324,7 @@ namespace dlib
...
@@ -317,7 +324,7 @@ namespace dlib
const
unsigned
long
idx
=
i
*
output_tensor
.
k
()
+
k
;
const
unsigned
long
idx
=
i
*
output_tensor
.
k
()
+
k
;
if
(
k
==
y
)
if
(
k
==
y
)
{
{
loss
+=
scale
*-
s
td
::
log
(
g
[
idx
]);
loss
+=
scale
*-
s
afe_
log
(
g
[
idx
]);
g
[
idx
]
=
scale
*
(
g
[
idx
]
-
1
);
g
[
idx
]
=
scale
*
(
g
[
idx
]
-
1
);
}
}
else
else
...
@@ -2139,7 +2146,7 @@ namespace dlib
...
@@ -2139,7 +2146,7 @@ namespace dlib
const
size_t
idx
=
tensor_index
(
output_tensor
,
i
,
k
,
r
,
c
);
const
size_t
idx
=
tensor_index
(
output_tensor
,
i
,
k
,
r
,
c
);
if
(
k
==
y
)
if
(
k
==
y
)
{
{
loss
+=
scale
*-
s
td
::
log
(
g
[
idx
]);
loss
+=
scale
*-
s
afe_
log
(
g
[
idx
]);
g
[
idx
]
=
scale
*
(
g
[
idx
]
-
1
);
g
[
idx
]
=
scale
*
(
g
[
idx
]
-
1
);
}
}
else
if
(
y
==
label_to_ignore
)
else
if
(
y
==
label_to_ignore
)
...
@@ -2285,7 +2292,7 @@ namespace dlib
...
@@ -2285,7 +2292,7 @@ namespace dlib
const
size_t
idx
=
tensor_index
(
output_tensor
,
i
,
k
,
r
,
c
);
const
size_t
idx
=
tensor_index
(
output_tensor
,
i
,
k
,
r
,
c
);
if
(
k
==
y
)
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
);
g
[
idx
]
=
weight
*
scale
*
(
g
[
idx
]
-
1
);
}
}
else
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