Commit 0f6ddb64 authored by Davis King's avatar Davis King

merged

parents 84d54e2f 6e6a7cfe
...@@ -1595,14 +1595,17 @@ namespace dlib ...@@ -1595,14 +1595,17 @@ namespace dlib
friend void to_xml(const affine_& item, std::ostream& out) friend void to_xml(const affine_& item, std::ostream& out)
{ {
out << "<affine";
if (item.mode==CONV_MODE) if (item.mode==CONV_MODE)
out << " mode='conv'"; out << "<affine_con>\n";
else else
out << " mode='fc'"; out << "<affine_fc>\n";
out << ">\n";
out << mat(item.params); out << mat(item.params);
out << "</affine>\n";
if (item.mode==CONV_MODE)
out << "</affine_con>\n";
else
out << "</affine_fc>\n";
} }
private: private:
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "core.h" #include "core.h"
#include "utilities_abstract.h" #include "utilities_abstract.h"
#include "../geometry.h" #include "../geometry.h"
#include <fstream>
namespace dlib namespace dlib
{ {
...@@ -103,9 +104,22 @@ namespace dlib ...@@ -103,9 +104,22 @@ namespace dlib
std::ostream& out std::ostream& out
) )
{ {
auto old_precision = out.precision(9);
out << "<net>\n"; out << "<net>\n";
visit_layers(net, impl::visitor_net_to_xml(out)); visit_layers(net, impl::visitor_net_to_xml(out));
out << "</net>\n"; out << "</net>\n";
// restore the original stream precision.
out.precision(old_precision);
}
template <typename net_type>
void net_to_xml (
const net_type& net,
const std::string& filename
)
{
std::ofstream fout(filename);
net_to_xml(net, fout);
} }
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
......
...@@ -56,6 +56,21 @@ namespace dlib ...@@ -56,6 +56,21 @@ namespace dlib
stream. stream.
!*/ !*/
template <typename net_type>
void net_to_xml (
const net_type& net,
const std::string& filename
);
/*!
requires
- net_type is an object of type add_layer, add_loss_layer, add_skip_layer, or
add_tag_layer.
- All layers in the net must provide to_xml() functions.
ensures
- This function is just like the above net_to_xml(), except it writes to a file
rather than an ostream.
!*/
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
template <typename net_type> template <typename net_type>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment