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
e1f2bb38
Commit
e1f2bb38
authored
May 26, 2017
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added visit_layers_until_tag()
parent
44387e39
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
97 additions
and
0 deletions
+97
-0
core.h
dlib/dnn/core.h
+65
-0
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