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
86bed7c1
Commit
86bed7c1
authored
Jun 11, 2016
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added visit_layers()
parent
2927671d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
0 deletions
+77
-0
core.h
dlib/dnn/core.h
+51
-0
core_abstract.h
dlib/dnn/core_abstract.h
+26
-0
No files found.
dlib/dnn/core.h
View file @
86bed7c1
...
...
@@ -3198,6 +3198,57 @@ namespace dlib
impl
::
vlpg_loop
<
0
,
net_type
::
num_layers
>::
visit
(
comp_i
,
net
,
v
);
}
// ----------------------------------------------------------------------------------------
namespace
impl
{
template
<
size_t
i
,
size_t
num
>
struct
vl_loop
{
template
<
typename
net_type
,
typename
visitor
>
static
void
visit
(
net_type
&
net
,
visitor
&&
v
)
{
v
(
i
,
layer
<
i
>
(
net
));
vl_loop
<
i
+
1
,
num
>::
visit
(
net
,
v
);
}
};
template
<
size_t
num
>
struct
vl_loop
<
num
,
num
>
{
template
<
typename
net_type
,
typename
visitor
>
static
void
visit
(
net_type
&
,
visitor
&&
)
{
// Base case of recursion. Don't do anything.
}
};
}
template
<
typename
net_type
,
typename
visitor
>
void
visit_layers
(
net_type
&
net
,
visitor
v
)
{
impl
::
vl_loop
<
0
,
net_type
::
num_layers
>::
visit
(
net
,
v
);
}
// ----------------------------------------------------------------------------------------
}
...
...
dlib/dnn/core_abstract.h
View file @
86bed7c1
...
...
@@ -1425,6 +1425,32 @@ namespace dlib
- When v() is called, the first argument is always < net_type::num_computational_layers.
!*/
// ----------------------------------------------------------------------------------------
template
<
typename
net_type
,
typename
visitor
>
void
visit_layers
(
net_type
&
net
,
visitor
v
);
/*!
requires
- net_type is an object of type add_layer, add_loss_layer, add_skip_layer, or
add_tag_layer.
- v is a function object with a signature equivalent to:
v(size_t idx, any_net_type& t)
That is, it must take a size_t and then any of the network types such as
add_layer, add_loss_layer, etc.
ensures
- Loops over all the layers in net and calls v() on them. To be specific, this
function essentially performs the following:
for (size_t i = 0; i < net_type::num_layers; ++i)
v(i, layer<i>(net));
!*/
// ----------------------------------------------------------------------------------------
struct
layer_test_results
...
...
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