当前位置: 首页>>代码示例>>Java>>正文


Java LinearClassifierFactory.useStochasticGradientDescentToQuasiNewton方法代码示例

本文整理汇总了Java中edu.stanford.nlp.classify.LinearClassifierFactory.useStochasticGradientDescentToQuasiNewton方法的典型用法代码示例。如果您正苦于以下问题:Java LinearClassifierFactory.useStochasticGradientDescentToQuasiNewton方法的具体用法?Java LinearClassifierFactory.useStochasticGradientDescentToQuasiNewton怎么用?Java LinearClassifierFactory.useStochasticGradientDescentToQuasiNewton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edu.stanford.nlp.classify.LinearClassifierFactory的用法示例。


在下文中一共展示了LinearClassifierFactory.useStochasticGradientDescentToQuasiNewton方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: trainMaxEnt

import edu.stanford.nlp.classify.LinearClassifierFactory; //导入方法依赖的package包/类
private void trainMaxEnt(Dataset<String, String> train) {
  int prior = LogPrior.LogPriorType.QUADRATIC.ordinal();
  if (flags.useHuber) {
    prior = LogPrior.LogPriorType.HUBER.ordinal();
  } else if (flags.useQuartic) {
    prior = LogPrior.LogPriorType.QUARTIC.ordinal();
  }

  LinearClassifier<String, String> lc;
  if (flags.useNB) {
    lc = new NBLinearClassifierFactory<String, String>(flags.sigma).trainClassifier(train);
  } else {
    LinearClassifierFactory<String, String> lcf = new LinearClassifierFactory<String, String>(flags.tolerance, flags.useSum, prior, flags.sigma, flags.epsilon, flags.QNsize);
    if (flags.useQN) {
      lcf.useQuasiNewton(flags.useRobustQN);
    } else if(flags.useStochasticQN) {
      lcf.useStochasticQN(flags.initialGain,flags.stochasticBatchSize);
    } else if(flags.useSMD) {
      lcf.useStochasticMetaDescent(flags.initialGain, flags.stochasticBatchSize,flags.stochasticMethod,flags.SGDPasses);
    } else if(flags.useSGD) {
      lcf.useStochasticGradientDescent(flags.gainSGD,flags.stochasticBatchSize);
    } else if(flags.useSGDtoQN) {
      lcf.useStochasticGradientDescentToQuasiNewton(flags.initialGain, flags.stochasticBatchSize,
                                     flags.SGDPasses, flags.QNPasses, flags.SGD2QNhessSamples,
                                     flags.QNsize, flags.outputIterationsToFile);
    } else if(flags.useHybrid) {
      lcf.useHybridMinimizer(flags.initialGain, flags.stochasticBatchSize ,flags.stochasticMethod ,flags.hybridCutoffIteration );
    } else {
      lcf.useConjugateGradientAscent();
    }
    lc = lcf.trainClassifier(train);
  }
  this.classifier = lc;
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:35,代码来源:CMMClassifier.java


注:本文中的edu.stanford.nlp.classify.LinearClassifierFactory.useStochasticGradientDescentToQuasiNewton方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。