Package cc.mallet.optimize

Examples of cc.mallet.optimize.LimitedMemoryBFGS


  }

  private Optimizer createMaxer (Optimizable.ByGradientValue macrf)
  {
    if (maxer == null) {
      return new LimitedMemoryBFGS (macrf);
    } else return maxer;
  }
View Full Code Here


   * Also creates an optimizable CRF if required.
   */
  public Optimizer getOptimizer (InstanceList trainingSet) {
    getOptimizableCRF(trainingSet); // this will set this.mcrf if necessary
    if (opt == null || ocrf != opt.getOptimizable())
      opt = new LimitedMemoryBFGS(ocrf)// Alternative: opt = new ConjugateGradient (0.001);
    return opt;
  }
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 Optimizer getOptimizer (InstanceList trainingSet) {
    getOptimizableCRF(trainingSet);
    if (optimizer == null || optimizable != optimizer.getOptimizable()) {
      optimizer = new LimitedMemoryBFGS(threadedOptimizable);
    }
    return optimizer;
  }
View Full Code Here

    // Build a new optimizer
    if (optimizer == null) {
      // If l1Weight is 0, this devolves to
      //  standard L-BFGS, but the implementation
      //  may be faster.
      optimizer = new LimitedMemoryBFGS(optimizable);
      //OrthantWiseLimitedMemoryBFGS(optimizable, l1Weight);
    }
    return optimizer;
  }
View Full Code Here

  }

  public Optimizer getOptimizer () {
    getOptimizable(trainingList);
    if (opt == null) {
      opt = new LimitedMemoryBFGS(ge);
    }
    return opt;
  }
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 Optimizer getOptimizer () {
    getOptimizable(trainingList);
    if (opt == null) {
      opt = new LimitedMemoryBFGS(ge);
    }
    return opt;
  }
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

        DMROptimizable optimizable = new DMROptimizable(parameterInstances, dmrParameters);
        optimizable.setRegularGaussianPriorVariance(0.5);
        optimizable.setInterceptGaussianPriorVariance(100.0);

    LimitedMemoryBFGS optimizer = new LimitedMemoryBFGS(optimizable);

    // Optimize once
    try {
      optimizer.optimize();
    } catch (OptimizationException e) {
      // step size too small
    }

    // Restart with a fresh initialization to improve likelihood
    try {
      optimizer.optimize();
    } catch (OptimizationException e) {
      // step size too small
    }
        dmrParameters = optimizable.getClassifier();
View Full Code Here

TOP

Related Classes of cc.mallet.optimize.LimitedMemoryBFGS

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.