mirror of
https://github.com/davisking/dlib.git
synced 2024-11-01 10:14:53 +08:00
merged
This commit is contained in:
commit
0f6ddb6471
@ -1595,14 +1595,17 @@ namespace dlib
|
||||
|
||||
friend void to_xml(const affine_& item, std::ostream& out)
|
||||
{
|
||||
out << "<affine";
|
||||
if (item.mode==CONV_MODE)
|
||||
out << " mode='conv'";
|
||||
out << "<affine_con>\n";
|
||||
else
|
||||
out << " mode='fc'";
|
||||
out << ">\n";
|
||||
out << "<affine_fc>\n";
|
||||
|
||||
out << mat(item.params);
|
||||
out << "</affine>\n";
|
||||
|
||||
if (item.mode==CONV_MODE)
|
||||
out << "</affine_con>\n";
|
||||
else
|
||||
out << "</affine_fc>\n";
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "core.h"
|
||||
#include "utilities_abstract.h"
|
||||
#include "../geometry.h"
|
||||
#include <fstream>
|
||||
|
||||
namespace dlib
|
||||
{
|
||||
@ -103,9 +104,22 @@ namespace dlib
|
||||
std::ostream& out
|
||||
)
|
||||
{
|
||||
auto old_precision = out.precision(9);
|
||||
out << "<net>\n";
|
||||
visit_layers(net, impl::visitor_net_to_xml(out));
|
||||
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
|
||||
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>
|
||||
|
Loading…
Reference in New Issue
Block a user