当前位置: 首页>>代码示例>>Java>>正文


Java CRFTrainerByThreadedLabelLikelihood类代码示例

本文整理汇总了Java中cc.mallet.fst.CRFTrainerByThreadedLabelLikelihood的典型用法代码示例。如果您正苦于以下问题:Java CRFTrainerByThreadedLabelLikelihood类的具体用法?Java CRFTrainerByThreadedLabelLikelihood怎么用?Java CRFTrainerByThreadedLabelLikelihood使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CRFTrainerByThreadedLabelLikelihood类属于cc.mallet.fst包,在下文中一共展示了CRFTrainerByThreadedLabelLikelihood类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: train

import cc.mallet.fst.CRFTrainerByThreadedLabelLikelihood; //导入依赖的package包/类
public CRF train() {
	t = 0;
	do {
		crf = new CRF(crf.getInputPipe(), crf.getOutputPipe());
		crf.addStatesForBiLabelsConnectedAsIn(Ds);
		trainer = new CRFTrainerByThreadedLabelLikelihood(crf, getThreads());
		trainer.train(Ds);
		trainer.shutdown();
		runEvaluators();
		t++;
		System.err.println("Finished iteration " + t);
		if (Rt.isEmpty())
			break;
		label();
		select();
	} while (!stop);
	return crf;
}
 
开发者ID:siqil,项目名称:udaner,代码行数:19,代码来源:CRFTrainerByBootstrapping.java

示例2: trainOnce

import cc.mallet.fst.CRFTrainerByThreadedLabelLikelihood; //导入依赖的package包/类
private TransducerTrainer trainOnce(Pipe pipe, InstanceList trainData) {
  Stopwatch watch = Stopwatch.createStarted();

  CRF crf = new CRF(pipe, null);
  crf.addOrderNStates(trainData, new int[]{1}, null, null, null, null, false);
  crf.addStartState();
  crf.setWeightsDimensionAsIn(trainData, false);
  if (initFrom != null) {
    crf.initializeApplicableParametersFrom(initFrom);
  }

  log.info("Starting alignTag training...");
  CRFTrainerByThreadedLabelLikelihood trainer = new CRFTrainerByThreadedLabelLikelihood(crf, 8);
  trainer.setGaussianPriorVariance(2);
  trainer.setAddNoFactors(true);
  trainer.setUseSomeUnsupportedTrick(false);
  trainer.train(trainData);
  trainer.shutdown();
  watch.stop();

  log.info("Syll align Tag CRF Training took " + watch.toString());
  crf.getInputAlphabet().stopGrowth();
  crf.getOutputAlphabet().stopGrowth();
  return trainer;
}
 
开发者ID:steveash,项目名称:jg2p,代码行数:26,代码来源:SyllTagTrainer.java

示例3: trainOnce

import cc.mallet.fst.CRFTrainerByThreadedLabelLikelihood; //导入依赖的package包/类
private TransducerTrainer trainOnce(Pipe pipe, InstanceList examples) {
    Stopwatch watch = Stopwatch.createStarted();

    CRF crf = new CRF(pipe, null);
    crf.addOrderNStates(examples, new int[]{1}, null, null, null, null, false);
    crf.addStartState();
//    crf.setWeightsDimensionAsIn(examples, false);

    log.info("Starting syllchain training...");
    CRFTrainerByThreadedLabelLikelihood trainer = new CRFTrainerByThreadedLabelLikelihood(crf, 8);
    trainer.setGaussianPriorVariance(2);
//    trainer.setUseSomeUnsupportedTrick(false);
//    trainer.setAddNoFactors(true);
    trainer.train(examples);
    trainer.shutdown();
    watch.stop();

    log.info("SyllChain CRF Training took " + watch.toString());
    crf.getInputAlphabet().stopGrowth();
    crf.getOutputAlphabet().stopGrowth();
    return trainer;
  }
 
开发者ID:steveash,项目名称:jg2p,代码行数:23,代码来源:StressTrainer.java

示例4: trainOnce

import cc.mallet.fst.CRFTrainerByThreadedLabelLikelihood; //导入依赖的package包/类
private TransducerTrainer trainOnce(Pipe pipe, InstanceList trainData) {
    Stopwatch watch = Stopwatch.createStarted();

    CRF crf = new CRF(pipe, null);
    crf.addOrderNStates(trainData, new int[]{1}, null, null, null, null, false);
    crf.addStartState();

    log.info("Starting alignTag training...");
    CRFTrainerByThreadedLabelLikelihood trainer = new CRFTrainerByThreadedLabelLikelihood(crf, 8);
    trainer.setGaussianPriorVariance(2);
//    trainer.setUseSomeUnsupportedTrick(false);
    trainer.train(trainData);
    trainer.shutdown();
    watch.stop();

    log.info("Align Tag CRF Training took " + watch.toString());
    crf.getInputAlphabet().stopGrowth();
    crf.getOutputAlphabet().stopGrowth();
    return trainer;
  }
 
开发者ID:steveash,项目名称:jg2p,代码行数:21,代码来源:AlignTagTrainer.java

示例5: trainOnce

import cc.mallet.fst.CRFTrainerByThreadedLabelLikelihood; //导入依赖的package包/类
private TransducerTrainer trainOnce(Pipe pipe, InstanceList examples) {
    Stopwatch watch = Stopwatch.createStarted();

    CRF crf = new CRF(pipe, null);
    crf.addOrderNStates(examples, new int[]{1}, null, null, null, null, false);
    crf.addStartState();
    crf.setWeightsDimensionAsIn(examples, true);

    if (initFrom != null) {
      crf.initializeApplicableParametersFrom(initFrom);
    }

    log.info("Starting syllchain training...");
    CRFTrainerByThreadedLabelLikelihood trainer = new CRFTrainerByThreadedLabelLikelihood(crf, 8);
    trainer.setGaussianPriorVariance(2);
    trainer.setAddNoFactors(true);
//    trainer.setUseSomeUnsupportedTrick(true);
    trainer.train(examples);
    trainer.shutdown();
    watch.stop();

    log.info("SyllChain CRF Training took " + watch.toString());
    crf.getInputAlphabet().stopGrowth();
    crf.getOutputAlphabet().stopGrowth();
    return trainer;
  }
 
开发者ID:steveash,项目名称:jg2p,代码行数:27,代码来源:SyllChainTrainer.java

示例6: trainOnce

import cc.mallet.fst.CRFTrainerByThreadedLabelLikelihood; //导入依赖的package包/类
private TransducerTrainer trainOnce(Pipe pipe, InstanceList trainData) {
  Stopwatch watch = Stopwatch.createStarted();

  CRF crf = new CRF(pipe, null);

  // O,O    O,N   -O,C-
  // N,O    N,N   N,C
  // C,O    ?C,N?   C,C
  Pattern forbidden = null;
  if (USE_ONC_CODING) {
    forbidden = Pattern.compile("(O,C|<START>,C|O,<END>)", Pattern.CASE_INSENSITIVE);
  }
  crf.addOrderNStates(trainData, new int[]{1}, null, null, forbidden, null, false);
  crf.addStartState();
  crf.setWeightsDimensionAsIn(trainData);

  if (this.pullFrom != null) {
    crf.initializeApplicableParametersFrom(pullFrom);
  }

  log.info("Starting syll phone training...");
  CRFTrainerByThreadedLabelLikelihood trainer = new CRFTrainerByThreadedLabelLikelihood(crf, 8);
  trainer.setGaussianPriorVariance(2);
  trainer.setAddNoFactors(false);
  trainer.setUseSomeUnsupportedTrick(true);
  trainer.train(trainData);
  trainer.shutdown();
  watch.stop();

  pipe.getAlphabet().stopGrowth();
  pipe.getTargetAlphabet().stopGrowth();
  log.info("Align Tag CRF Training took " + watch.toString());
  return trainer;
}
 
开发者ID:steveash,项目名称:jg2p,代码行数:35,代码来源:PhoneSyllTagTrainer.java

示例7: makeNewTrainer

import cc.mallet.fst.CRFTrainerByThreadedLabelLikelihood; //导入依赖的package包/类
private static CRFTrainerByThreadedLabelLikelihood makeNewTrainer(CRF crf) {
  CRFTrainerByThreadedLabelLikelihood trainer = new CRFTrainerByThreadedLabelLikelihood(crf, getCpuCount());
  trainer.setGaussianPriorVariance(2);
  trainer.setAddNoFactors(true);
  trainer.setUseSomeUnsupportedTrick(false);
  return trainer;
}
 
开发者ID:steveash,项目名称:jg2p,代码行数:8,代码来源:PhonemeCrfTrainer.java

示例8: evaluate

import cc.mallet.fst.CRFTrainerByThreadedLabelLikelihood; //导入依赖的package包/类
/** MultiSegmentationEvaluator */
    private static Fold evaluate(int iterationId, CRF crf,
            InstanceList trainingSet, InstanceList testingSet, int threads) {

        // TODO 1 see if it works (better) with simpler setup

        CRFTrainerByThreadedLabelLikelihood trainer = new CRFTrainerByThreadedLabelLikelihood(
                crf, threads);
        // CRFTrainerByLabelLikelihood trainer = new
        // CRFTrainerByLabelLikelihood(crf);
        trainer.setGaussianPriorVariance(1);

        String[] tags = new String[] { Jcas2TokenSequence.TARGET_I };
        String[] continueTags = tags;

        trainer.train(trainingSet);

        MyMultiSegmentationEvaluator eval = new MyMultiSegmentationEvaluator(
                new InstanceList[] { testingSet },//
                new String[] { "TTesting" }, tags, continueTags,
                PRINT_MISSCLASSIFIED);
        eval.evaluate(trainer); // eval at end of training

//        MultiSegmentationEvaluator evalOrig = new MultiSegmentationEvaluator(
//                new InstanceList[] { testingSet },//
//                new String[] { "TTesting" }, tags, continueTags);
//        evalOrig.evaluate(trainer); // eval at end of training

        LenientMultiSegmentationEvaluator evalLenient = new LenientMultiSegmentationEvaluator(
                new InstanceList[] { testingSet },//
                new String[] { "TTesting" }, tags, continueTags,
                PRINT_MISSCLASSIFIED);
        evalLenient.evaluate(trainer);

        LOG.info("FOLD {} --> " + eval + " lenient: {}", iterationId,
                evalLenient);
        return new Fold(eval);

        // TODO trainer.trainWithFeatureInduction

        // TODO
        // if ( runner.isInduceFeatures() ) {
        // // Number of maximizer iterations between each call to the Feature
        // Inducer. (10 in simpletagger and TUI)
        // int numIterationsBetweenFeatureInductions = 10;
        //
        // // Maximum number of rounds of feature induction. (20 in
        // simpleTagger, 99 in TUI)
        // int numFeatureInductions = 20;
        //
        // // Maximum number of features to induce at each round of induction.
        // (500 in simpletagger, 200 in TUI)
        // int numFeaturesPerFeatureInduction = 300;
        // // splits = new double[] {.1, .2, .5, .7}
        //
        // crft.trainWithFeatureInduction( training, null, testing, eval,
        // iterations,
        // numIterationsBetweenFeatureInductions, numFeatureInductions,
        // numFeaturesPerFeatureInduction, 0.5,
        // false, null );
        // } else {
        // // before
        // converged = crft.train( training ); // , iterations );
        // }
    }
 
开发者ID:BlueBrain,项目名称:bluima,代码行数:66,代码来源:BrainRegionAnnotator.java


注:本文中的cc.mallet.fst.CRFTrainerByThreadedLabelLikelihood类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。