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
c41b30a8
Commit
c41b30a8
authored
May 07, 2017
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added missing sig and prelu layer support.
parent
af40aa1b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
2 deletions
+23
-2
main.cpp
tools/convert_dlib_nets_to_caffe/main.cpp
+23
-2
No files found.
tools/convert_dlib_nets_to_caffe/main.cpp
View file @
c41b30a8
...
@@ -175,6 +175,17 @@ void convert_dlib_xml_to_cafffe_python_code(
...
@@ -175,6 +175,17 @@ void convert_dlib_xml_to_cafffe_python_code(
fout
<<
" n."
<<
i
->
caffe_layer_name
()
<<
" = L.ReLU(n."
<<
find_input_layer_caffe_name
(
i
);
fout
<<
" n."
<<
i
->
caffe_layer_name
()
<<
" = L.ReLU(n."
<<
find_input_layer_caffe_name
(
i
);
fout
<<
");
\n
"
;
fout
<<
");
\n
"
;
}
}
else
if
(
i
->
detail_name
==
"sig"
)
{
fout
<<
" n."
<<
i
->
caffe_layer_name
()
<<
" = L.Sigmoid(n."
<<
find_input_layer_caffe_name
(
i
);
fout
<<
");
\n
"
;
}
else
if
(
i
->
detail_name
==
"prelu"
)
{
fout
<<
" n."
<<
i
->
caffe_layer_name
()
<<
" = L.PReLU(n."
<<
find_input_layer_caffe_name
(
i
);
fout
<<
", channel_shared=True"
;
fout
<<
");
\n
"
;
}
else
if
(
i
->
detail_name
==
"max_pool"
)
else
if
(
i
->
detail_name
==
"max_pool"
)
{
{
fout
<<
" n."
<<
i
->
caffe_layer_name
()
<<
" = L.Pooling(n."
<<
find_input_layer_caffe_name
(
i
);
fout
<<
" n."
<<
i
->
caffe_layer_name
()
<<
" = L.Pooling(n."
<<
find_input_layer_caffe_name
(
i
);
...
@@ -284,9 +295,10 @@ void convert_dlib_xml_to_cafffe_python_code(
...
@@ -284,9 +295,10 @@ void convert_dlib_xml_to_cafffe_python_code(
fout
<<
" net.save(weights_file);
\n\n
"
;
fout
<<
" net.save(weights_file);
\n\n
"
;
// -------------------------
// -------------------------
// -----------------------------------------------------------------------------------
// The next block of code outputs python code that populates all the filter weights.
// -----------------------------------------------------------------------------------
fout
<<
"def set_network_weights(net):
\n
"
;
fout
<<
"def set_network_weights(net):
\n
"
;
fout
<<
" # populate network parameters
\n
"
;
fout
<<
" # populate network parameters
\n
"
;
...
@@ -354,6 +366,15 @@ void convert_dlib_xml_to_cafffe_python_code(
...
@@ -354,6 +366,15 @@ void convert_dlib_xml_to_cafffe_python_code(
fout
<<
" p.shape = net.params['"
<<
i
->
caffe_layer_name
()
<<
"'][1].data.shape;
\n
"
;
fout
<<
" p.shape = net.params['"
<<
i
->
caffe_layer_name
()
<<
"'][1].data.shape;
\n
"
;
fout
<<
" net.params['"
<<
i
->
caffe_layer_name
()
<<
"'][1].data[:] = p;
\n
"
;
fout
<<
" net.params['"
<<
i
->
caffe_layer_name
()
<<
"'][1].data[:] = p;
\n
"
;
}
}
else
if
(
i
->
detail_name
==
"prelu"
)
{
const
double
param
=
i
->
params
(
0
);
// main filter weights
fout
<<
" tmp = net.params['"
<<
i
->
caffe_layer_name
()
<<
"'][0].data.view();
\n
"
;
fout
<<
" tmp.shape = 1;
\n
"
;
fout
<<
" tmp[0] = "
<<
param
<<
";
\n
"
;
}
}
}
}
}
...
...
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