本文整理汇总了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;
}