This commit is contained in:
Davis King 2016-01-08 18:16:34 -05:00
commit f47620c11f
2 changed files with 39 additions and 0 deletions

View File

@ -5,6 +5,7 @@
#include "running_gradient_abstract.h"
#include "../algs.h"
#include "../serialize.h"
#include <cmath>
#include "../matrix.h"
@ -115,6 +116,28 @@ namespace dlib
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:
static double normal_cfd(double value, double mean, double stddev)

View File

@ -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_