summaryrefslogtreecommitdiff
path: root/training/cllh_observer.cc
diff options
context:
space:
mode:
authorChris Dyer <cdyer@allegro.clab.cs.cmu.edu>2012-11-18 13:35:42 -0500
committerChris Dyer <cdyer@allegro.clab.cs.cmu.edu>2012-11-18 13:35:42 -0500
commit8aa29810bb77611cc20b7a384897ff6703783ea1 (patch)
tree8635daa8fffb3f2cd90e30b41e27f4f9e0909447 /training/cllh_observer.cc
parentfbdacabc85bea65d735f2cb7f92b98e08ce72d04 (diff)
major restructure of the training code
Diffstat (limited to 'training/cllh_observer.cc')
-rw-r--r--training/cllh_observer.cc52
1 files changed, 0 insertions, 52 deletions
diff --git a/training/cllh_observer.cc b/training/cllh_observer.cc
deleted file mode 100644
index 4ec2fa65..00000000
--- a/training/cllh_observer.cc
+++ /dev/null
@@ -1,52 +0,0 @@
-#include "cllh_observer.h"
-
-#include <cmath>
-#include <cassert>
-
-#include "inside_outside.h"
-#include "hg.h"
-#include "sentence_metadata.h"
-
-using namespace std;
-
-static const double kMINUS_EPSILON = -1e-6;
-
-ConditionalLikelihoodObserver::~ConditionalLikelihoodObserver() {}
-
-void ConditionalLikelihoodObserver::NotifyDecodingStart(const SentenceMetadata&) {
- cur_obj = 0;
- state = 1;
-}
-
-void ConditionalLikelihoodObserver::NotifyTranslationForest(const SentenceMetadata&, Hypergraph* hg) {
- assert(state == 1);
- state = 2;
- SparseVector<prob_t> cur_model_exp;
- const prob_t z = InsideOutside<prob_t,
- EdgeProb,
- SparseVector<prob_t>,
- EdgeFeaturesAndProbWeightFunction>(*hg, &cur_model_exp);
- cur_obj = log(z);
-}
-
-void ConditionalLikelihoodObserver::NotifyAlignmentForest(const SentenceMetadata& smeta, Hypergraph* hg) {
- assert(state == 2);
- state = 3;
- SparseVector<prob_t> ref_exp;
- const prob_t ref_z = InsideOutside<prob_t,
- EdgeProb,
- SparseVector<prob_t>,
- EdgeFeaturesAndProbWeightFunction>(*hg, &ref_exp);
-
- double log_ref_z = log(ref_z);
-
- // rounding errors means that <0 is too strict
- if ((cur_obj - log_ref_z) < kMINUS_EPSILON) {
- cerr << "DIFF. ERR! log_model_z < log_ref_z: " << cur_obj << " " << log_ref_z << endl;
- exit(1);
- }
- assert(!std::isnan(log_ref_z));
- acc_obj += (cur_obj - log_ref_z);
- trg_words += smeta.GetReference().size();
-}
-