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
b401185a
Commit
b401185a
authored
Aug 23, 2020
by
Davis King
Browse files
Fix a warning and add some more error handling.
parent
dd06c116
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
4 deletions
+12
-4
dlib/dnn/loss.h
dlib/dnn/loss.h
+5
-0
dlib/dnn/loss_abstract.h
dlib/dnn/loss_abstract.h
+3
-2
dlib/test/dnn.cpp
dlib/test/dnn.cpp
+4
-2
No files found.
dlib/dnn/loss.h
View file @
b401185a
...
...
@@ -852,6 +852,11 @@ namespace dlib
const
float
*
out_data
=
output_tensor
.
host
();
for
(
long
i
=
0
;
i
<
output_tensor
.
num_samples
();
++
i
,
++
truth
)
{
const
long
long
num_label_categories
=
truth
->
size
();
DLIB_CASSERT
(
output_tensor
.
k
()
==
num_label_categories
,
"Number of label types should match the number of output channels. "
"output_tensor.k(): "
<<
output_tensor
.
k
()
<<
", num_label_categories: "
<<
num_label_categories
);
for
(
long
k
=
0
;
k
<
output_tensor
.
k
();
++
k
)
{
const
float
y
=
(
*
truth
)[
k
];
...
...
dlib/dnn/loss_abstract.h
View file @
b401185a
...
...
@@ -767,8 +767,9 @@ namespace dlib
- sub.get_output().nc() == 1
- sub.get_output().num_samples() == input_tensor.num_samples()
- sub.sample_expansion_factor() == 1
- all values pointed to by truth are std::vectors of non-zero elements.
Nominally they should be +1 or -1, each indicating the desired class label.
- truth points to training_label_type elements, each of size sub.get_output.k().
The elements of each truth training_label_type instance are nominally +1 or -1,
each representing a binary class label.
!*/
};
...
...
dlib/test/dnn.cpp
View file @
b401185a
...
...
@@ -3391,11 +3391,13 @@ namespace
{
for
(
size_t
j
=
0
;
j
<
labels
[
i
].
size
();
++
j
)
{
if
(
labels
[
i
][
j
]
==
1
&&
preds
[
i
][
j
]
<
0
||
labels
[
i
][
j
]
==
0
&&
preds
[
i
][
j
]
>
0
)
if
((
labels
[
i
][
j
]
==
1
&&
preds
[
i
][
j
]
<
0
)
||
(
labels
[
i
][
j
]
==
0
&&
preds
[
i
][
j
]
>
0
))
{
++
num_wrong
;
}
}
}
return
num_wrong
/
labels
.
size
()
/
dims
;
};
...
...
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