//nbest MIRA public void taskRunner_nbestMIRA(object task) { int i = (int)task; foreach (dataSeq x in Global.threadX[i]) { //find the output nbest path List <double> logNumers = new List <double>(); List <List <int> > taggingList = new List <List <int> >(); AStarSearch aStar = new AStarSearch(); aStar.getNBest(_model, _inf, x, Global.nBest, ref taggingList, ref logNumers); //oracle Viterbi path List <int> goldStates = new List <int>(x.getTags()); foreach (List <int> outStates in taggingList) { int diff = listTool.compare(outStates, goldStates); if (diff > 0) { updateWeights(x, outStates, goldStates, _model.W, _tmpW, Global.xsize, Global.k, diff); Global.wUpdate++; } } Global.k++; Global.countWithIter++; } }
public void taskRunner(object task) { int i = (int)task; foreach (dataSeq x in Global.threadX[i]) { //find the output nbest path List <List <int> > taggingList = new List <List <int> >(); List <double> logNumers = new List <double>(); AStarSearch aStar = new AStarSearch(); Global.threadError[i] += aStar.getNBest(_model, _inf, x, Global.nBest, ref taggingList, ref logNumers); //oracle Viterbi path List <int> goldStates = new List <int>(x.getTags()); Global.r_k = Global.rate0 * Math.Pow(Global.decayFactor, (double)Global.countWithIter / (double)Global.xsize); if (Global.countWithIter % (Global.xsize / 4) == 0) { Global.swLog.WriteLine("iter{0} decay_rate={1}", Global.glbIter, Global.r_k.ToString("e2")); } if (taggingList.Count == 1 && listTool.compare(taggingList[0], goldStates) == 0) { Global.k++; Global.countWithIter++; continue; } else { //update the weights updateWeights(x, taggingList, logNumers, goldStates, _model.W, Global.xsize, Global.k); Global.wUpdate++; Global.k++; Global.countWithIter++; } } }