TRF Language Model
trf::MLfunc Class Reference

#include <trf-ml-train.h>

Inheritance diagram for trf::MLfunc:
wb::Func trf::SAfunc

Public Member Functions

 MLfunc ()
 
 MLfunc (Model *pModel, CorpusBase *pTrain, CorpusBase *pValid=NULL, CorpusBase *pTest=NULL)
 
void Reset (Model *pModel, CorpusBase *pTrain, CorpusBase *pValid=NULL, CorpusBase *pTest=NULL)
 
virtual void SetParam (double *pdParams)
 set the parameter. More...
 
void GetParam (double *pdParams)
 
virtual double GetLL (CorpusBase *pCorpus, int nCalNum=-1, Vec< double > *pLL=NULL)
 calculate the log-likelihood on corpus More...
 
void GetEmpExp (CorpusBase *pCorpus, Vec< double > &vExp)
 get the empirical expectation More...
 
virtual double GetValue ()
 calculate the function value f(x) More...
 
virtual void GetGradient (double *pdGradient)
 calculate the gradient g(x) More...
 
virtual int GetExtraValues (int t, double *pdValues)
 calculate extra values which will be print at each iteration More...
 
- Public Member Functions inherited from wb::Func
 Func (int nParamNum=0)
 
void SetParamNum (int n)
 setting the parameter number More...
 
int GetParamNum () const
 get the paremeter number More...
 

Public Attributes

const char * m_pathOutputModel
 Write to model during iteration. More...
 

Protected Attributes

Modelm_pModel
 HRF model. More...
 
Vec< PValuem_value
 save the temp value of type PValue. More...
 
CorpusBasem_pCorpusTrain
 training corpus More...
 
CorpusBasem_pCorpusValid
 valid corpus More...
 
CorpusBasem_pCorpusTest
 test corpus More...
 
Vec< Probm_trainPi
 the length distribution in training corpus More...
 
Vec< double > m_vEmpiricalExp
 the empirical expectation More...
 
- Protected Attributes inherited from wb::Func
Solvem_pSolve
 Save the solve pointor. More...
 
int m_nParamNum
 the parameter number More...
 

Additional Inherited Members

- Static Public Attributes inherited from wb::Func
static const int cn_exvalue_max_num = 100
 

Detailed Description

Definition at line 30 of file trf-ml-train.h.

Constructor & Destructor Documentation

§ MLfunc() [1/2]

trf::MLfunc::MLfunc ( )
inline

Definition at line 47 of file trf-ml-train.h.

§ MLfunc() [2/2]

trf::MLfunc::MLfunc ( Model pModel,
CorpusBase pTrain,
CorpusBase pValid = NULL,
CorpusBase pTest = NULL 
)

Definition at line 23 of file trf-ml-train.cpp.

Member Function Documentation

§ GetEmpExp()

void trf::MLfunc::GetEmpExp ( CorpusBase pCorpus,
Vec< double > &  vExp 
)

get the empirical expectation

Definition at line 146 of file trf-ml-train.cpp.

§ GetExtraValues()

int trf::MLfunc::GetExtraValues ( int  k,
double *  pdValues 
)
virtual

calculate extra values which will be print at each iteration

Parameters
[in]kiteration number form 1 to ...
[out]pdValuesReturn the values needed to be outputed. The memory is allocated outside and the maximum size = cn_exvalue_max_num
Returns
return the pdValues number

Reimplemented from wb::Func.

Reimplemented in trf::SAfunc.

Definition at line 200 of file trf-ml-train.cpp.

§ GetGradient()

void trf::MLfunc::GetGradient ( double *  pdGradient)
virtual

calculate the gradient g(x)

Implements wb::Func.

Reimplemented in trf::SAfunc.

Definition at line 183 of file trf-ml-train.cpp.

§ GetLL()

double trf::MLfunc::GetLL ( CorpusBase pCorpus,
int  nCalNum = -1,
Vec< double > *  pLL = NULL 
)
virtual

calculate the log-likelihood on corpus

Definition at line 102 of file trf-ml-train.cpp.

§ GetParam()

void trf::MLfunc::GetParam ( double *  pdParams)

Definition at line 91 of file trf-ml-train.cpp.

§ GetValue()

double trf::MLfunc::GetValue ( )
virtual

calculate the function value f(x)

Implements wb::Func.

Reimplemented in trf::SAfunc.

Definition at line 175 of file trf-ml-train.cpp.

§ Reset()

void trf::MLfunc::Reset ( Model pModel,
CorpusBase pTrain,
CorpusBase pValid = NULL,
CorpusBase pTest = NULL 
)

Check maximum length

calculate the length distribution in training corpus

get empirical expectation

Definition at line 29 of file trf-ml-train.cpp.

§ SetParam()

void trf::MLfunc::SetParam ( double *  pdParams)
virtual

set the parameter.

Implements wb::Func.

Reimplemented in trf::SAfunc.

Definition at line 79 of file trf-ml-train.cpp.

Member Data Documentation

§ m_pathOutputModel

const char* trf::MLfunc::m_pathOutputModel

Write to model during iteration.

Definition at line 44 of file trf-ml-train.h.

§ m_pCorpusTest

CorpusBase* trf::MLfunc::m_pCorpusTest
protected

test corpus

Definition at line 38 of file trf-ml-train.h.

§ m_pCorpusTrain

CorpusBase* trf::MLfunc::m_pCorpusTrain
protected

training corpus

Definition at line 36 of file trf-ml-train.h.

§ m_pCorpusValid

CorpusBase* trf::MLfunc::m_pCorpusValid
protected

valid corpus

Definition at line 37 of file trf-ml-train.h.

§ m_pModel

Model* trf::MLfunc::m_pModel
protected

HRF model.

Definition at line 33 of file trf-ml-train.h.

§ m_trainPi

Vec<Prob> trf::MLfunc::m_trainPi
protected

the length distribution in training corpus

Definition at line 40 of file trf-ml-train.h.

§ m_value

Vec<PValue> trf::MLfunc::m_value
protected

save the temp value of type PValue.

Definition at line 34 of file trf-ml-train.h.

§ m_vEmpiricalExp

Vec<double> trf::MLfunc::m_vEmpiricalExp
protected

the empirical expectation

Definition at line 42 of file trf-ml-train.h.


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