41 AISConfig(
int p_nChain = 16,
int p_nInter = 1000) :nChain(p_nChain), nInter(p_nInter){}
44 char *p = strtok(tempStr.
GetBuffer(),
":,");
46 p = strtok(NULL,
":,");
58 void Create(
int maxlen,
Model *pModel);
128 Reset(pModel, pTrain, pValid, pTest, nMinibatch);
133 for (
int i = 0; i < m_threadSeq.
GetNum(); i++) {
149 void GetParam(
double *pdParams);
157 void IterEnd(
double *pFinalParams);
159 void WriteModel(
int nEpoch);
161 virtual void SetParam(
double *pdParams);
162 virtual void GetGradient(
double *pdGradient);
164 virtual int GetExtraValues(
int t,
double *pdValues);
179 void Reset(
const char *pstr,
int p_t0);
224 m_pAlgorithmName =
"[SAMS]";
231 m_bUpdate_lambda =
true;
232 m_bUpdate_zeta =
true;
240 m_avgHes.
Reset(pfunc->GetFeatNum());
248 adam_m.
Reset(pfunc->GetFeatNum());
249 adam_v.
Reset(pfunc->GetFeatNum());
255 virtual bool Run(
const double *pInitParams = NULL);
257 void UpdateGamma(
int nIterNum);
259 void UpdateDir(
double *pDir,
double *pGradient,
const double *pParam);
261 virtual void Update(
double *pdParam,
const double *pdDir,
double dStep);
int m_nAvgBeg
if >0, then calculate the average
int nInter
intermediate distribution number
Vec< double > m_vSampleExp2
the sample expectation^2
Vec< double > m_vAllSampleLenCount
the count of each length in all samples
Vec< Prob > m_samplePi
the length distribution used for sample
#define SAFE_DELETE(p)
memory release
Vec< double > m_vCurSampleLenCount
the count of length in samples of current iteration
Mat< double > m_matSampleLen
the length count of sample of each thread
int GetFeatNum() const
get the ngram feature number
the base class of all the solve classes, and provide a gradient descent algorithm.
Mat< double > m_matSampleExp
the sample expectation of each thread
double m_fRegL2
l2 regularization
File m_fparm
output the parameters of each iteration
Vec< double > m_vEmpiricalVar
empirical variance
int m_nCDSampleTimes
the CD-n: the sample number.
int m_nTotalSample
the total sample number
File m_fmean
output the p[f] on training set
File m_fgrad
output the gradient of each iteration
AISConfig(int p_nChain=16, int p_nInter=1000)
void Parse(const char *str)
double m_var_gap
a varicance gap used in gradient sacling
Mat< double > m_matSampleExp2
the sample expectation^2 of each thread
int GetZetaNum() const
get the zeta parameter number
define a sequence including the word sequence and class sequence
AISConfig m_AISConfigForZ
the AIS configuration for normalization
File m_fvallidLL
output loglikelihood on valid set
File m_ftrainLL
output loglikelihood on training set
SAfunc(Model *pModel, CorpusBase *pTrain, CorpusBase *pValid=NULL, CorpusBase *pTest=NULL, int nMinibatch=100)
File m_ftrain
output all the training sequences
wb::Array< int > m_aWriteAtIter
output temp model at some iteration
File m_fvar
output the variance at each iteration
int m_nMiniBatchSample
mini-batch for samples
Vec< double > m_vSampleLen
the sample length expectation
virtual double GetValue()
calculate the function value f(x)
File m_fdbg
output the sample pi/zete information
File m_fexp
output the expectation of each iteartion
int GetNum() const
Get Array number.
LearningRate m_gain_lambda
int m_nSASampleTimes
the SA sample times
Array< Seq * > m_threadSeq
save the last sequence of each threads
double m_dir_gap
control the dir values
char * GetBuffer() const
get buffer
int m_nPrintPerIter
output the LL per iteration, if ==-1, the disable
SAtrain(SAfunc *pfunc=NULL)
float m_fEpochNun
the current epoch number - double
AISConfig m_AISConfigForP
the AIS configuration for calculating the LL.
Vec< double > m_vSampleExp
the sample expectation
File m_ftestLL
output loglikelihood on test set
File m_fsamp
output all the samples