TRF Language Model
hrf::MLfunc Class Reference

#include <hrf-ml-train.h>

Inheritance diagram for hrf::MLfunc:
wb::Func hrf::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)
 
ModelGetModel () const
 
virtual void SetParam (double *pdParams)
 set the parameter. More...
 
void GetParam (double *pdParams)
 
virtual double GetLL (CorpusBase *pCorpus, int nCalNum=-1)
 calculate the log-likelihood on corpus 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...
 
CorpusBasem_pCorpusTrain
 training corpus More...
 
CorpusBasem_pCorpusValid
 valid corpus More...
 
CorpusBasem_pCorpusTest
 test corpus More...
 
Vec< PValuem_values
 
Vec< Probm_trainPi
 the length distribution in training corpus 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 15 of file hrf-ml-train.h.

Constructor & Destructor Documentation

§ MLfunc() [1/2]

hrf::MLfunc::MLfunc ( )
inline

Definition at line 31 of file hrf-ml-train.h.

§ MLfunc() [2/2]

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

Definition at line 6 of file hrf-ml-train.cpp.

Member Function Documentation

§ GetExtraValues()

int hrf::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 hrf::SAfunc.

Definition at line 193 of file hrf-ml-train.cpp.

§ GetGradient()

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

calculate the gradient g(x)

Implements wb::Func.

Reimplemented in hrf::SAfunc.

Definition at line 149 of file hrf-ml-train.cpp.

§ GetLL()

double hrf::MLfunc::GetLL ( CorpusBase pCorpus,
int  nCalNum = -1 
)
virtual

calculate the log-likelihood on corpus

Definition at line 78 of file hrf-ml-train.cpp.

§ GetModel()

Model* hrf::MLfunc::GetModel ( ) const
inline

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

§ GetParam()

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

Definition at line 68 of file hrf-ml-train.cpp.

§ GetValue()

double hrf::MLfunc::GetValue ( )
virtual

calculate the function value f(x)

Implements wb::Func.

Reimplemented in hrf::SAfunc.

Definition at line 141 of file hrf-ml-train.cpp.

§ Reset()

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

Check maximum length

calculate the length distribution in training corpus

Definition at line 12 of file hrf-ml-train.cpp.

§ SetParam()

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

set the parameter.

Implements wb::Func.

Reimplemented in hrf::SAfunc.

Definition at line 57 of file hrf-ml-train.cpp.

Member Data Documentation

§ m_pathOutputModel

const char* hrf::MLfunc::m_pathOutputModel

Write to model during iteration.

Definition at line 28 of file hrf-ml-train.h.

§ m_pCorpusTest

CorpusBase* hrf::MLfunc::m_pCorpusTest
protected

test corpus

Definition at line 22 of file hrf-ml-train.h.

§ m_pCorpusTrain

CorpusBase* hrf::MLfunc::m_pCorpusTrain
protected

training corpus

Definition at line 20 of file hrf-ml-train.h.

§ m_pCorpusValid

CorpusBase* hrf::MLfunc::m_pCorpusValid
protected

valid corpus

Definition at line 21 of file hrf-ml-train.h.

§ m_pModel

Model* hrf::MLfunc::m_pModel
protected

HRF model.

Definition at line 18 of file hrf-ml-train.h.

§ m_trainPi

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

the length distribution in training corpus

Definition at line 25 of file hrf-ml-train.h.

§ m_values

Vec<PValue> hrf::MLfunc::m_values
protected

Definition at line 24 of file hrf-ml-train.h.


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