From 1903cdb1edaf05d82d8782d446f1d2c39eb05f0c Mon Sep 17 00:00:00 2001 From: redpony Date: Sun, 29 Aug 2010 00:36:09 +0000 Subject: online optimizer git-svn-id: https://ws10smt.googlecode.com/svn/trunk@631 ec762483-ff6d-05da-a07a-a48fb63a330f --- training/optimize.cc | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'training/optimize.cc') diff --git a/training/optimize.cc b/training/optimize.cc index 5194752e..1377caa6 100644 --- a/training/optimize.cc +++ b/training/optimize.cc @@ -7,9 +7,9 @@ using namespace std; -Optimizer::~Optimizer() {} +BatchOptimizer::~BatchOptimizer() {} -void Optimizer::Save(ostream* out) const { +void BatchOptimizer::Save(ostream* out) const { out->write((const char*)&eval_, sizeof(eval_)); out->write((const char*)&has_converged_, sizeof(has_converged_)); SaveImpl(out); @@ -17,7 +17,7 @@ void Optimizer::Save(ostream* out) const { out->write((const char*)&magic, sizeof(magic)); } -void Optimizer::Load(istream* in) { +void BatchOptimizer::Load(istream* in) { in->read((char*)&eval_, sizeof(eval_)); ++eval_; in->read((char*)&has_converged_, sizeof(has_converged_)); @@ -28,11 +28,11 @@ void Optimizer::Load(istream* in) { cerr << Name() << " EVALUATION #" << eval_ << endl; } -void Optimizer::SaveImpl(ostream* out) const { +void BatchOptimizer::SaveImpl(ostream* out) const { (void)out; } -void Optimizer::LoadImpl(istream* in) { +void BatchOptimizer::LoadImpl(istream* in) { (void)in; } @@ -78,18 +78,6 @@ void RPropOptimizer::LoadImpl(istream* in) { in->read((char*)&delta_ij_[0], sizeof(double) * n); } -string SGDOptimizer::Name() const { - return "SGDOptimizer"; -} - -void SGDOptimizer::OptimizeImpl(const double& obj, - const vector& g, - vector* x) { - (void)obj; - for (int i = 0; i < g.size(); ++i) - (*x)[i] -= g[i] * eta_; -} - string LBFGSOptimizer::Name() const { return "LBFGSOptimizer"; } -- cgit v1.2.3