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
c41b30a8
"docs/vscode:/vscode.git/clone" did not exist on "3eaead0c4a55bf11bdf832eaa61d0e87fe5464df"
Commit
c41b30a8
authored
May 07, 2017
by
Davis King
Browse files
Added missing sig and prelu layer support.
parent
af40aa1b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
2 deletions
+23
-2
tools/convert_dlib_nets_to_caffe/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(
fout
<<
" n."
<<
i
->
caffe_layer_name
()
<<
" = L.ReLU(n."
<<
find_input_layer_caffe_name
(
i
);
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"
)
{
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(
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
<<
" # populate network parameters
\n
"
;
...
...
@@ -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
<<
" 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