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
86bed7c1
Commit
86bed7c1
authored
Jun 11, 2016
by
Davis King
Browse files
Added visit_layers()
parent
2927671d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
0 deletions
+77
-0
dlib/dnn/core.h
dlib/dnn/core.h
+51
-0
dlib/dnn/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
...
@@ -3198,6 +3198,57 @@ namespace dlib
impl
::
vlpg_loop
<
0
,
net_type
::
num_layers
>::
visit
(
comp_i
,
net
,
v
);
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
...
@@ -1425,6 +1425,32 @@ namespace dlib
- When v() is called, the first argument is always < net_type::num_computational_layers.
- 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
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