?? maxentclassifierfactory.java
字號:
package edu.stanford.nlp.classify;import java.util.*;import edu.stanford.nlp.util.*;import edu.stanford.nlp.optimization.*;/** @author Dan Klein */public class MaxentClassifierFactory extends AbstractLinearClassifierFactory { double TOL = 1e-4; double sigma = 1.0; boolean verbose = false; public double[][] trainWeights(int[][] data, int[] labels) { Minimizer minimizer = new CGMinimizer(!verbose); DiffFunction objective = new LogConditionalObjectiveFunction(numFeatures(), numClasses(), data, labels, sigma); double[] weights = minimizer.minimize(objective, TOL, ((HasInitial)objective).initial()); //System.err.println("Final derivative norm2: "+((AbstractCachingDiffFunction)objective).norm2(((AbstractCachingDiffFunction)objective).derivative)); return ((LogConditionalObjectiveFunction)objective).to2D(weights); } /** Set the smoothing amount: 1.0 is the default. */ public void setSigma(double sigma) { this.sigma = sigma; } public void setTol(double tol) { TOL = tol; } public void setVerbose(boolean verbose) { this.verbose = verbose; }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -