diff options
author | Chris Dyer <cdyer@cs.cmu.edu> | 2011-11-11 17:12:39 -0500 |
---|---|---|
committer | Chris Dyer <cdyer@cs.cmu.edu> | 2011-11-11 17:12:39 -0500 |
commit | 105a52a8d37497fe69a01a7de771ef9b9300cd71 (patch) | |
tree | f20c4cc8bf31ccf1ce7204301bfa169c6fa080a7 /decoder/hg_sampler.h | |
parent | b4fd470d2cb80b0c88d4210f7e5bb10d2aa4531d (diff) |
optionally sample from forest to get training instances, rather than k-best it
Diffstat (limited to 'decoder/hg_sampler.h')
-rw-r--r-- | decoder/hg_sampler.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/decoder/hg_sampler.h b/decoder/hg_sampler.h new file mode 100644 index 00000000..bf4e1eb0 --- /dev/null +++ b/decoder/hg_sampler.h @@ -0,0 +1,27 @@ +#ifndef _HG_SAMPLER_H_ +#define _HG_SAMPLER_H_ + + +#include <vector> +#include "sparse_vector.h" +#include "sampler.h" +#include "wordid.h" + +class Hypergraph; + +struct HypergraphSampler { + + struct Hypothesis { + std::vector<WordID> words; + SparseVector<double> fmap; + prob_t model_score; // log unnormalized probability + }; + + static void + sample_hypotheses(const Hypergraph& hg, + unsigned n, // how many samples to draw + MT19937* rng, + std::vector<Hypothesis>* hypos); +}; + +#endif |