diff options
author | Chris Dyer <cdyer@cs.cmu.edu> | 2011-12-29 23:02:50 -0500 |
---|---|---|
committer | Chris Dyer <cdyer@cs.cmu.edu> | 2011-12-29 23:02:50 -0500 |
commit | 031dc91814c1b57269b8a789c93aad0da0a46b6b (patch) | |
tree | 212c04385b6bdf65679b0a8c1ba87a168bb74b6e /gi | |
parent | 68870390f6c6429af2b9c182ad28e8a78a0f1752 (diff) |
remove broken prior, add logging
Diffstat (limited to 'gi')
-rw-r--r-- | gi/pf/align-lexonly.cc | 36 |
1 files changed, 2 insertions, 34 deletions
diff --git a/gi/pf/align-lexonly.cc b/gi/pf/align-lexonly.cc index 91a3cfcf..7e48b25a 100644 --- a/gi/pf/align-lexonly.cc +++ b/gi/pf/align-lexonly.cc @@ -66,41 +66,9 @@ struct AlignedSentencePair { Array2D<short> posterior; }; -struct HierarchicalUnigramBase { - explicit HierarchicalUnigramBase(const unsigned vocab_e_size) : r(5,5), u0(1.0 / vocab_e_size) {} - - // return p0 of rule.e_ - prob_t operator()(const TRule& rule) const { - prob_t p = prob_t::One(); - prob_t q; - for (unsigned i = 0; i < rule.e_.size(); ++i) { - q.logeq(r.logprob(rule.e_[i], log(u0))); - p *= q; - } - q.logeq(r.logprob(TD::Convert("</s>"), log(u0))); - p *= q; - return p; - } - - void Increment(const TRule& rule) { - for (unsigned i = 0; i < rule.e_.size(); ++i) - r.increment(rule.e_[i]); - r.increment(TD::Convert("</s>")); - } - - void Decrement(const TRule& rule) { - for (unsigned i = 0; i < rule.e_.size(); ++i) - r.decrement(rule.e_[i]); - r.decrement(TD::Convert("</s>")); - } - - CCRP_NoTable<WordID> r; - prob_t u0; -}; - struct HierarchicalWordBase { explicit HierarchicalWordBase(const unsigned vocab_e_size) : - base(prob_t::One()), r(15,15), u0(-log(vocab_e_size)) {} + base(prob_t::One()), r(25,25,10), u0(-log(vocab_e_size)) {} void ResampleHyperparameters(MT19937* rng) { r.resample_hyperparameters(rng); @@ -137,7 +105,7 @@ struct HierarchicalWordBase { } void Summary() const { - cerr << "NUMBER OF CUSTOMERS: " << r.num_customers() << endl; + cerr << "NUMBER OF CUSTOMERS: " << r.num_customers() << " (\\alpha=" << r.concentration() << ')' << endl; for (CCRP_NoTable<vector<WordID> >::const_iterator it = r.begin(); it != r.end(); ++it) cerr << " " << it->second << '\t' << TD::GetString(it->first) << endl; } |