TRF Language Model
trf::Model_FastSample Class Reference

TRF model, revise the sample method to speedup the MCMC. More...

#include <trf-model.h>

Inheritance diagram for trf::Model_FastSample:
trf::Model

Public Member Functions

 Model_FastSample (Vocab *pv)
 
 Model_FastSample (Vocab *pv, int maxlen)
 
LogP ProposeW0 (VocabID &wi, Seq &seq, int nPos, bool bSample=true)
 
void ProposeCProbs (VecShell< LogP > &logps, Seq &seq, int nPos)
 
void MarkovMove (Seq &seq)
 [sample] Markov Move - perform the gibbs sampling More...
 
void SamplePos (Seq &seq, int nPos)
 
- Public Member Functions inherited from trf::Model
 Model (Vocab *pv)
 constructor More...
 
 Model (Vocab *pv, int maxlen)
 constructor More...
 
 ~Model ()
 destructor More...
 
int GetMaxLen () const
 Get max-len. More...
 
VocabGetVocab () const
 Get Vocab. More...
 
int GetMaxOrder () const
 Get maximum order. More...
 
int GetParamNum () const
 Get parameter number. More...
 
void Reset (Vocab *pv, int maxlen)
 reset, the maxlen is the length excluding the beg/end symbols. More...
 
virtual void SetParam (PValue *pValue)
 Set the parameters. More...
 
void GetParam (PValue *pValue)
 Get the paremetre vector. More...
 
void SetPi (Prob *pPi)
 Set the pi. More...
 
template<typename T >
void SetZeta (T *pzeta)
 Set updated zeta. More...
 
template<typename T >
void GetZeta (T *pzeta)
 
LogP GetLogProb (Seq &seq, bool bNorm=true)
 calculate the probability More...
 
void LoadFromCorpus (const char *pcorpus, const char *pfeatstyle, int nOrder)
 load ngram features from corpus More...
 
void FeatCount (Seq &seq, double *pCount, double dadd=1.0)
 Count the feature number in a sequence. More...
 
void ReadT (const char *pfilename)
 Read Model. More...
 
void WriteT (const char *pfilename)
 Write Model. More...
 
LogP ClusterSum (Seq &seq, int nPos, int nOrder)
 Read Binary. More...
 
virtual double ExactNormalize (int nLen)
 [exact] Exact Normalization, return the logz of given length More...
 
virtual void ExactNormalize ()
 [exact] Exact Normalization More...
 
void GetNodeExp (int nLen, double *pExp)
 [exact] E_{p_l}[f]: Exactly calculate the expectation over x and h for length nLen More...
 
void GetNodeExp (double *pExp, Prob *pLenProb=NULL)
 [exact] sum_l { n_l/n * E_{p_l}[f] }: Exactly calculate the expectation over x and h More...
 
void Sample (Seq &seq)
 [sample] Perform one train-dimensional mixture sampling More...
 
void LocalJump (Seq &seq)
 [sample] Local Jump - sample a new length More...
 
LogP ProposeLength (int nOld, int &nNew, bool bSample)
 [sample] Propose the length, using the variable m_matLenJump More...
 
LogP ProposeC0 (VocabID &ci, Seq &seq, int nPos, bool bSample)
 [sample] Propose the c_{i} at position i. Then return the propose probability R(c_i|h_i,c_{other}) More...
 
void ProposeCProbs (VecShell< LogP > &logps, Seq &seq, int nPos)
 [sample] Return the propose distribution of c_i at position nPos More...
 
LogP GetReducedModelForC (Seq &seq, int nPos)
 [sample] A unnormalized reduced model to sample class c_i. More...
 
LogP GetReducedModelForW (Seq &seq, int nPos)
 [sample] A unnormalized reduced model to sample word w_i. More...
 
LogP GetReducedModel (Seq &seq, int nPos)
 [sample] A unnormalized reduced depending on nPos. More...
 
LogP GetMarginalProbOfC (Seq &seq, int nPos)
 [sample] given c_i, summate the probabilities of x_i, i.e. P(c_i) More...
 
void SampleC (Seq &seq, int nPos)
 [sample] Sample the c_i at position nPos without x_i. More...
 
LogP SampleX (Seq &seq, int nPos, bool bSample=true)
 [sample] Sample the x_i at position nPos More...
 
LogP AISNormalize (int nLen, int nChain, int nInter)
 perform AIS to calculate the normalization constants, return the logz of given length More...
 
void AISNormalize (int nLenMin, int nLenMax, int nChain, int nInter)
 

Public Attributes

int m_nMHtimes
 
- Public Attributes inherited from trf::Model
Featm_pFeat
 hash all the features More...
 
Vec< PValuem_value
 the value for each features More...
 
int m_maxlen
 the maximum length of model, excluding <s> and </s>. The min-len = 1 More...
 
Vec< Probm_pi
 the prior length distribution More...
 
Vec< LogPm_logz
 the normalization constants log Z_l More...
 
Vec< LogPm_zeta
 the estimated normalization constants (fix = 0) More...
 
Vocabm_pVocab
 
Mat< Probm_matLenJump
 [sample] used to propose a new length More...
 
int m_maxSampleLen
 [sample] the maximum sample length, default = m_maxlen + 2 More...
 
int m_nLenJumpAccTimes
 lenght jump the acceptance times More...
 
int m_nLenJumpTotalTime
 total times of length jump More...
 
int m_nSampleHAccTimes
 sample H the acceptance times More...
 
int m_nSampleHTotalTimes
 

Additional Inherited Members

- Protected Attributes inherited from trf::Model
AlgNode m_AlgNode
 the forward-backward calculation each node More...
 

Detailed Description

TRF model, revise the sample method to speedup the MCMC.

Definition at line 217 of file trf-model.h.

Constructor & Destructor Documentation

§ Model_FastSample() [1/2]

trf::Model_FastSample::Model_FastSample ( Vocab pv)
inline

Definition at line 222 of file trf-model.h.

§ Model_FastSample() [2/2]

trf::Model_FastSample::Model_FastSample ( Vocab pv,
int  maxlen 
)
inline

Definition at line 225 of file trf-model.h.

Member Function Documentation

§ MarkovMove()

void trf::Model_FastSample::MarkovMove ( Seq seq)
inlinevirtual

[sample] Markov Move - perform the gibbs sampling

Reimplemented from trf::Model.

Definition at line 276 of file trf-model.h.

§ ProposeCProbs()

void trf::Model_FastSample::ProposeCProbs ( VecShell< LogP > &  logps,
Seq seq,
int  nPos 
)
inline

Definition at line 265 of file trf-model.h.

§ ProposeW0()

LogP trf::Model_FastSample::ProposeW0 ( VocabID wi,
Seq seq,
int  nPos,
bool  bSample = true 
)
inline

Definition at line 228 of file trf-model.h.

§ SamplePos()

void trf::Model_FastSample::SamplePos ( Seq seq,
int  nPos 
)
inline

Definition at line 281 of file trf-model.h.

Member Data Documentation

§ m_nMHtimes

int trf::Model_FastSample::m_nMHtimes

Definition at line 220 of file trf-model.h.


The documentation for this class was generated from the following file: