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
e1f2bb38
"...tensorflow/git@developer.sourcefind.cn:OpenDAS/dgl.git" did not exist on "611393021a85e10ccd433a264a3487726b7b1841"
Commit
e1f2bb38
authored
May 26, 2017
by
Davis King
Browse files
Added visit_layers_until_tag()
parent
44387e39
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
97 additions
and
0 deletions
+97
-0
dlib/dnn/core.h
dlib/dnn/core.h
+65
-0
dlib/dnn/core_abstract.h
dlib/dnn/core_abstract.h
+32
-0
No files found.
dlib/dnn/core.h
View file @
e1f2bb38
...
@@ -3475,6 +3475,71 @@ namespace dlib
...
@@ -3475,6 +3475,71 @@ namespace dlib
impl
::
vl_loop_backwards
<
begin
,
end
>::
visit
(
net
,
v
);
impl
::
vl_loop_backwards
<
begin
,
end
>::
visit
(
net
,
v
);
}
}
// ----------------------------------------------------------------------------------------
namespace
impl
{
template
<
size_t
i
,
unsigned
long
tag_id
>
struct
vl_until_tag
{
template
<
typename
net_type
,
typename
next_net_type
,
typename
visitor
>
static
void
visit
(
net_type
&
net
,
next_net_type
&
next_net
,
visitor
&&
v
)
{
v
(
next_net
);
vl_until_tag
<
i
+
1
,
tag_id
>::
visit
(
net
,
layer
<
i
+
1
>
(
net
),
v
);
}
template
<
typename
net_type
,
typename
SUBNET
,
typename
visitor
>
static
void
visit
(
net_type
&
net
,
const
add_tag_layer
<
tag_id
,
SUBNET
>&
next_net
,
visitor
&&
v
)
{
v
(
next_net
);
}
template
<
typename
net_type
,
typename
SUBNET
,
typename
visitor
>
static
void
visit
(
net_type
&
net
,
add_tag_layer
<
tag_id
,
SUBNET
>&
next_net
,
visitor
&&
v
)
{
v
(
next_net
);
}
};
}
template
<
unsigned
long
tag_id
,
typename
net_type
,
typename
visitor
>
void
visit_layers_until_tag
(
net_type
&
net
,
visitor
v
)
{
impl
::
vl_until_tag
<
0
,
tag_id
>::
visit
(
net
,
net
,
v
);
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
}
}
...
...
dlib/dnn/core_abstract.h
View file @
e1f2bb38
...
@@ -1578,6 +1578,38 @@ namespace dlib
...
@@ -1578,6 +1578,38 @@ namespace dlib
v(i-1, layer<i-1>(net));
v(i-1, layer<i-1>(net));
!*/
!*/
// ----------------------------------------------------------------------------------------
template
<
unsigned
long
tag_id
,
typename
net_type
,
typename
visitor
>
void
visit_layers_until_tag
(
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(any_net_type& t)
That is, it must take any of the network types such as add_layer,
add_loss_layer, etc.
ensures
- Loops over all the layers in net beginning with layer<0>(net) and going until
a tag layer with an ID of tag_id is encountered. To be specific, this
function essentially performs the following:
size_t i = 0;
while(layer<i>(net) isn't an add_tag_layer with ID == tag_id) {
v(layer<i>(net));
++i;
}
v(layer<i>(net)); // also visits the tag layer itself at the very end.
!*/
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
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