diff options
author | redpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-08-29 00:36:09 +0000 |
---|---|---|
committer | redpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-08-29 00:36:09 +0000 |
commit | 1903cdb1edaf05d82d8782d446f1d2c39eb05f0c (patch) | |
tree | 0873c3ce979b6ef5476ce0ae735f434763ce97d1 /training/optimize.cc | |
parent | fabdc7bc3cd5a83c2c74768bfc46146b4f3221b4 (diff) |
online optimizer
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@631 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'training/optimize.cc')
-rw-r--r-- | training/optimize.cc | 22 |
1 files changed, 5 insertions, 17 deletions
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<double>& g, - vector<double>* x) { - (void)obj; - for (int i = 0; i < g.size(); ++i) - (*x)[i] -= g[i] * eta_; -} - string LBFGSOptimizer::Name() const { return "LBFGSOptimizer"; } |