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
846a5704
Commit
846a5704
authored
Jan 23, 2016
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added an overload of operator() that lets you easily run a network on an
entire std::vector of objects.
parent
93ab80c7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
0 deletions
+36
-0
core.h
dlib/dnn/core.h
+16
-0
core_abstract.h
dlib/dnn/core_abstract.h
+20
-0
No files found.
dlib/dnn/core.h
View file @
846a5704
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
#include <utility>
#include <utility>
#include <tuple>
#include <tuple>
#include <cmath>
#include <cmath>
#include <vector>
#include "tensor_tools.h"
#include "tensor_tools.h"
...
@@ -1922,6 +1923,21 @@ namespace dlib
...
@@ -1922,6 +1923,21 @@ namespace dlib
return
temp_label
;
return
temp_label
;
}
}
std
::
vector
<
label_type
>
operator
()
(
const
std
::
vector
<
input_type
>&
data
,
size_t
batch_size
=
128
)
{
std
::
vector
<
label_type
>
results
(
data
.
size
());
auto
o
=
results
.
begin
();
for
(
auto
i
=
data
.
begin
();
i
<
data
.
end
();
i
+=
batch_size
,
o
+=
batch_size
)
{
auto
end
=
std
::
min
(
i
+
batch_size
,
data
.
end
());
(
*
this
)(
i
,
end
,
o
);
}
return
results
;
}
template
<
typename
label_iterator
>
template
<
typename
label_iterator
>
double
compute_loss
(
double
compute_loss
(
const
tensor
&
x
,
const
tensor
&
x
,
...
...
dlib/dnn/core_abstract.h
View file @
846a5704
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
#include <memory>
#include <memory>
#include <type_traits>
#include <type_traits>
#include <tuple>
#include <tuple>
#include <vector>
#include "../rand.h"
#include "../rand.h"
...
@@ -687,6 +688,25 @@ namespace dlib
...
@@ -687,6 +688,25 @@ namespace dlib
label_type.
label_type.
!*/
!*/
std
::
vector
<
label_type
>
operator
()
(
const
std
::
vector
<
input_type
>&
data
,
size_t
batch_size
=
128
);
/*!
requires
- batch_size > 0
ensures
- runs all the objects in data through the network and returns their
predicted labels. This means this function returns a vector V such that:
- V.size() == data.size()
- for all valid i: V[i] == the predicted label of data[i].
- Elements of data are run through the network in batches of batch_size
items. Using a batch_size > 1 can be faster because it better exploits
the available hardware parallelism.
- loss_details().to_label() is used to convert the network output into a
label_type.
!*/
// -------------
// -------------
template
<
typename
label_iterator
>
template
<
typename
label_iterator
>
...
...
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