Package cc.mallet.fst

Examples of cc.mallet.fst.CRFOptimizableByLabelLikelihood


    }
   
    // train semi-supervised
    Optimizable.ByGradientValue optLikelihood;
    if (numThreads == 1) {
      optLikelihood = new CRFOptimizableByLabelLikelihood(crf,trainingSet);
      ((CRFOptimizableByLabelLikelihood)optLikelihood).setGaussianPriorVariance(gpv);
    }
    else {
      CRFOptimizableByBatchLabelLikelihood likelihood = new CRFOptimizableByBatchLabelLikelihood(crf,trainingSet,numThreads);
      optLikelihood = new ThreadedOptimizable(likelihood,trainingSet,crf.getParameters().getNumFactors(),
View Full Code Here


   * @return True if training has converged.
   */
  public boolean train(InstanceList labeled, InstanceList unlabeled, int numIterations) {
    if (iteration == 0) {
      // train with log-likelihood only first
      CRFOptimizableByLabelLikelihood likelihood =
        new CRFOptimizableByLabelLikelihood(crf, labeled);
      likelihood.setGaussianPriorVariance(gaussianPriorVariance);
      this.bfgs = new LimitedMemoryBFGS(likelihood);
      logger.info ("CRF about to train with "+numIterations+" iterations");
      for (int i = 0; i < numIterations; i++) {
        try {
          converged = bfgs.optimize(1);
          iteration++;
          logger.info ("CRF finished one iteration of maximizer, i="+i);
          runEvaluators();
        } catch (IllegalArgumentException e) {
          e.printStackTrace();
          logger.info ("Catching exception; saying converged.");
          converged = true;
        } catch (Exception e) {
          e.printStackTrace();
          logger.info("Catching exception; saying converged.");
          converged = true;
        }
        if (converged) {
          logger.info ("CRF training has converged, i="+i);
          break;
        }
      }
      iteration = 0;
    }
   
    // train with log-likelihood + entropy regularization
    CRFOptimizableByLabelLikelihood likelihood = new CRFOptimizableByLabelLikelihood(crf, labeled);
    likelihood.setGaussianPriorVariance(gaussianPriorVariance);
    CRFOptimizableByEntropyRegularization regularization = new CRFOptimizableByEntropyRegularization(crf, unlabeled);
    regularization.setScalingFactor(this.entRegScalingFactor);
   
    CRFOptimizableByGradientValues regLikelihood = new CRFOptimizableByGradientValues(crf,
        new Optimizable.ByGradientValue[] { likelihood, regularization} );
View Full Code Here

   * @return True if training has converged.
   */
  public boolean train(InstanceList labeled, InstanceList unlabeled, int numIterations) {
    if (iteration == 0) {
      // train with log-likelihood only first
      CRFOptimizableByLabelLikelihood likelihood =
        new CRFOptimizableByLabelLikelihood(crf, labeled);
      likelihood.setGaussianPriorVariance(gaussianPriorVariance);
      this.bfgs = new LimitedMemoryBFGS(likelihood);
      logger.info ("CRF about to train with "+numIterations+" iterations");
      for (int i = 0; i < numIterations; i++) {
        try {
          converged = bfgs.optimize(1);
          iteration++;
          logger.info ("CRF finished one iteration of maximizer, i="+i);
          runEvaluators();
        } catch (IllegalArgumentException e) {
          e.printStackTrace();
          logger.info ("Catching exception; saying converged.");
          converged = true;
        } catch (Exception e) {
          e.printStackTrace();
          logger.info("Catching exception; saying converged.");
          converged = true;
        }
        if (converged) {
          logger.info ("CRF training has converged, i="+i);
          break;
        }
      }
      iteration = 0;
    }
   
    // train with log-likelihood + entropy regularization
    CRFOptimizableByLabelLikelihood likelihood = new CRFOptimizableByLabelLikelihood(crf, labeled);
    likelihood.setGaussianPriorVariance(gaussianPriorVariance);
    CRFOptimizableByEntropyRegularization regularization = new CRFOptimizableByEntropyRegularization(crf, unlabeled);
    regularization.setScalingFactor(this.entRegScalingFactor);
   
    CRFOptimizableByGradientValues regLikelihood = new CRFOptimizableByGradientValues(crf,
        new Optimizable.ByGradientValue[] { likelihood, regularization} );
View Full Code Here

TOP

Related Classes of cc.mallet.fst.CRFOptimizableByLabelLikelihood

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.