Commit ab2cd129 authored by Davis King's avatar Davis King

Made running_gradient serializable.

parent 5435c56d
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "running_gradient_abstract.h" #include "running_gradient_abstract.h"
#include "../algs.h" #include "../algs.h"
#include "../serialize.h"
#include <cmath> #include <cmath>
#include "../matrix.h" #include "../matrix.h"
...@@ -115,6 +116,28 @@ namespace dlib ...@@ -115,6 +116,28 @@ namespace dlib
return 1-probability_gradient_less_than(thresh); return 1-probability_gradient_less_than(thresh);
} }
friend void serialize (const running_gradient& item, std::ostream& out)
{
int version = 1;
serialize(version, out);
serialize(item.n, out);
serialize(item.R, out);
serialize(item.w, out);
serialize(item.residual_squared, out);
}
friend void deserialize (running_gradient& item, std::ostream& in)
{
int version = 0;
deserialize(version, in);
if (version != 1)
throw serialization_error("Unexpected version found while deserializing dlib::running_gradient.");
deserialize(item.n, in);
deserialize(item.R, in);
deserialize(item.w, in);
deserialize(item.residual_squared, in);
}
private: private:
static double normal_cfd(double value, double mean, double stddev) static double normal_cfd(double value, double mean, double stddev)
......
...@@ -100,6 +100,22 @@ namespace dlib ...@@ -100,6 +100,22 @@ namespace dlib
!*/ !*/
}; };
void serialize (
const running_gradient& item,
std::ostream& out
);
/*!
provides serialization support
!*/
void deserialize (
running_gradient& item,
std::istream& in
);
/*!
provides serialization support
!*/
} }
#endif // DLIB_RuNNING_GRADIENT_ABSTRACT_Hh_ #endif // DLIB_RuNNING_GRADIENT_ABSTRACT_Hh_
......
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