TRF Language Model
hrf-ml-train.h
Go to the documentation of this file.
1 #pragma once
2 #include "hrf-model.h"
3 #include "trf-corpus.h"
4 #include "wb-solve.h"
5 using namespace wb;
6 
7 namespace hrf
8 {
10 
15  class MLfunc : public Func
16  {
17  protected:
19 
20  CorpusBase *m_pCorpusTrain;
21  CorpusBase *m_pCorpusValid;
22  CorpusBase *m_pCorpusTest;
23 
26 
27  public:
28  const char *m_pathOutputModel;
29 
30  public:
31  MLfunc() :m_pModel(NULL), m_pCorpusTrain(NULL), m_pCorpusValid(NULL), m_pCorpusTest(NULL) {
32  m_pathOutputModel = NULL;
33  };
34  MLfunc(Model *pModel, CorpusBase *pTrain, CorpusBase *pValid = NULL, CorpusBase *pTest = NULL);
35  void Reset(Model *pModel, CorpusBase *pTrain, CorpusBase *pValid = NULL, CorpusBase *pTest = NULL);
36  Model *GetModel() const { return m_pModel; }
37  virtual void SetParam(double *pdParams);
38  void GetParam(double *pdParams);
40  /* - if nCalNum = -1, calculate all the sequences in corpus;
41  - if nCalNum != -1, calculate the first min(nNum, curpus number) sequences.
42  */
43  virtual double GetLL(CorpusBase *pCorpus, int nCalNum = -1);
44 
45  virtual double GetValue(/*double *pdParams*/);
46  virtual void GetGradient(/*double *pdParams, */double *pdGradient);
47  virtual int GetExtraValues(int t, /*double *pdParams, */double *pdValues);
48  };
49 }
const char * m_pathOutputModel
Write to model during iteration.
Definition: hrf-ml-train.h:28
Model * GetModel() const
Definition: hrf-ml-train.h:36
hidden-random-field model
Definition: hrf-model.h:98
trf::CorpusBase CorpusBase
Definition: hrf-ml-train.h:9
CorpusBase * m_pCorpusTrain
training corpus
Definition: hrf-ml-train.h:20
Vec< PValue > m_values
Definition: hrf-ml-train.h:24
Vec< Prob > m_trainPi
the length distribution in training corpus
Definition: hrf-ml-train.h:25
CorpusBase * m_pCorpusValid
valid corpus
Definition: hrf-ml-train.h:21
define the framework of iterative algorithms, such as gradient descent or LBFGS.
Model * m_pModel
HRF model.
Definition: hrf-ml-train.h:18
the objective function, used to derive
Definition: wb-solve.h:39
define all the code written by Bin Wang.
Definition: wb-file.cpp:21
CorpusBase * m_pCorpusTest
test corpus
Definition: hrf-ml-train.h:22