Package cc.mallet.optimize

Examples of cc.mallet.optimize.Optimizer


                        InstanceList testSet,
                        ACRFEvaluator eval,
                        int numIter,
                        Optimizable.ByGradientValue macrf)
  {
    Optimizer maximizer = createMaxer (macrf);
//    Maximizer.ByGradient maximizer = new BoldDriver ();
//    Maximizer.ByGradient maximizer = new GradientDescent ();
    boolean converged = false;
    boolean resetOnError = true;
    long stime = System.currentTimeMillis ();

    int numNodes = (macrf instanceof ACRF.MaximizableACRF) ? ((ACRF.MaximizableACRF) macrf).getTotalNodes () : 0;
    double thresh = 1e-5 * numNodes; // "early" stopping (reasonably conservative)

    if (testSet == null) {
      logger.warning ("ACRF trainer: No test set provided.");
    }

    double prevValue = Double.NEGATIVE_INFINITY;
    double currentValue;
    int iter;
    for (iter = 0; iter < numIter; iter++) {
      long etime = new java.util.Date ().getTime ();
      logger.info ("ACRF trainer iteration " + iter + " at time " + (etime - stime));

      try {
        converged = maximizer.optimize (1);
        converged |= callEvaluator (acrf, trainingList, validationList, testSet, iter, eval);

        if (converged) break;
        resetOnError = true;

View Full Code Here


    */

    omemm = new MEMMOptimizableByLabelLikelihood (memm, training);
    // Gather the constraints
    omemm.gatherExpectationsOrConstraints (true);
    Optimizer maximizer = new LimitedMemoryBFGS(omemm);
    int i;
//    boolean continueTraining = true;
    boolean converged = false;
    logger.info ("CRF about to train with "+numIterations+" iterations");
    for (i = 0; i < numIterations; i++) {
      try {
        converged = maximizer.optimize (1);
        logger.info ("CRF finished one iteration of maximizer, i="+i);
        runEvaluators();
      } catch (IllegalArgumentException e) {
        e.printStackTrace();
        logger.info ("Catching exception; saying converged.");
View Full Code Here

  public MaxEnt train (InstanceList trainingSet)
  {
    logger.fine ("trainingSet.size() = "+trainingSet.size());
    RankMaxEntTrainer.MaximizableTrainer mt =
      new RankMaxEntTrainer.MaximizableTrainer (trainingSet, (RankMaxEnt)initialClassifier);
    Optimizer maximizer = new LimitedMemoryBFGS(mt);

  //  maximizer.optimize (); // XXX given the loop below, this seems wrong.
     boolean converged;

     for (int i = 0; i < numIterations; i++) {
      try {
        converged = maximizer.optimize (1);
      } catch (IllegalArgumentException e) {
        e.printStackTrace();
        logger.info ("Catching exception; saying converged.");
        converged = true;
      }
View Full Code Here

  public MCMaxEnt train (InstanceList trainingSet)
  {
    logger.fine ("trainingSet.size() = "+trainingSet.size());
    mt = new MaximizableTrainer (trainingSet, (MCMaxEnt)initialClassifier);
    Optimizer maximizer = new LimitedMemoryBFGS(mt);
    // CPAL - change the tolerance for large vocab experiments
    ((LimitedMemoryBFGS)maximizer).setTolerance(.00001);    // std is .0001;
    maximizer.optimize (); // XXX given the loop below, this seems wrong.

    logger.info("MCMaxEnt ngetValueCalls:"+getValueCalls()+"\nMCMaxEnt ngetValueGradientCalls:"+getValueGradientCalls());
//    boolean converged;
//
//     for (int i = 0; i < numIterations; i++) {
View Full Code Here

                        InstanceList testSet,
                        ACRFEvaluator eval,
                        int numIter,
                        Optimizable.ByGradientValue macrf)
  {
    Optimizer maximizer = createMaxer (macrf);
//    Maximizer.ByGradient maximizer = new BoldDriver ();
//    Maximizer.ByGradient maximizer = new GradientDescent ();
    boolean converged = false;
    boolean resetOnError = true;
    long stime = System.currentTimeMillis ();

    int numNodes = (macrf instanceof ACRF.MaximizableACRF) ? ((ACRF.MaximizableACRF) macrf).getTotalNodes () : 0;
    double thresh = 1e-5 * numNodes; // "early" stopping (reasonably conservative)

    if (testSet == null) {
      logger.warning ("ACRF trainer: No test set provided.");
    }

    double prevValue = Double.NEGATIVE_INFINITY;
    double currentValue;
    int iter;
    for (iter = 0; iter < numIter; iter++) {
      long etime = new java.util.Date ().getTime ();
      logger.info ("ACRF trainer iteration " + iter + " at time " + (etime - stime));

      try {
        converged = maximizer.optimize (1);
        converged |= callEvaluator (acrf, trainingList, validationList, testSet, iter, eval);

        if (converged) break;
        resetOnError = true;

View Full Code Here

TOP

Related Classes of cc.mallet.optimize.Optimizer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.