Package cc.mallet.types

Examples of cc.mallet.types.InstanceList


  public void doTestSpacePrediction(boolean testValueAndGradient) {
    Pipe p = makeSpacePredictionPipe();
    Pipe p2 = new TestCRF2String();

    InstanceList instances = new InstanceList(p);
    instances.addThruPipe(new ArrayIterator(data));
    InstanceList[] lists = instances.split(new Random(1), new double[] {
        .5, .5 });
    CRF crf = new CRF(p, p2);
    crf.addFullyConnectedStatesForLabels();
    CRFTrainerByLabelLikelihood crft = new CRFTrainerByLabelLikelihood(crf);
    if (testValueAndGradient) {
View Full Code Here


      boolean useSaved, boolean useSparseWeights) {
    Pipe p = makeSpacePredictionPipe();

    CRF savedCRF;
    File f = new File("TestObject.obj");
    InstanceList instances = new InstanceList(p);
    instances.addThruPipe(new ArrayIterator(data));
    InstanceList[] lists = instances.split(new double[] { .5, .5 });
    CRF crf = new CRF(p.getDataAlphabet(), p.getTargetAlphabet());
    crf.addFullyConnectedStatesForLabels();
    CRFTrainerByLabelLikelihood crft = new CRFTrainerByLabelLikelihood(crf);
    crft.setUseSparseWeights(useSparseWeights);
    if (testValueAndGradient) {
View Full Code Here

  }

  public void testAddOrderNStates() {
    Pipe p = makeSpacePredictionPipe();

    InstanceList instances = new InstanceList(p);
    instances.addThruPipe(new ArrayIterator(data));
    InstanceList[] lists = instances.split(new java.util.Random(678),
        new double[] { .5, .5 });

    // Compare 3 CRFs trained with addOrderNStates, and make sure
    // that having more features leads to a higher likelihood
View Full Code Here

  }

  public void testFrozenWeights() {
    Pipe p = makeSpacePredictionPipe();

    InstanceList instances = new InstanceList(p);
    instances.addThruPipe(new ArrayIterator(data));

    CRF crf1 = new CRF(p.getDataAlphabet(), p.getTargetAlphabet());
    crf1.addFullyConnectedStatesForLabels();
    CRFTrainerByLabelLikelihood crft1 = new CRFTrainerByLabelLikelihood(
        crf1);
View Full Code Here

  public void testTrainStochasticGradient() {
    Pipe p = makeSpacePredictionPipe();
    Pipe p2 = new TestCRF2String();

    InstanceList instances = new InstanceList(p);
    instances.addThruPipe(new ArrayIterator(data));
    InstanceList[] lists = instances.split(new double[] { .5, .5 });
    CRF crf = new CRF(p, p2);
    crf.addFullyConnectedStatesForLabels();
    crf.setWeightsDimensionAsIn(lists[0], false);
    CRFTrainerByStochasticGradient crft = new CRFTrainerByStochasticGradient(
        crf, 0.0001);
View Full Code Here

  public void testSumLatticeImplementations() {
    Pipe p = makeSpacePredictionPipe();
    Pipe p2 = new TestCRF2String();

    // first do normal training for getting weights
    InstanceList instances = new InstanceList(p);
    instances.addThruPipe(new ArrayIterator(data));
    InstanceList[] lists = instances.split(new double[] { .5, .5 });
    CRF crf = new CRF(p, p2);
    crf.addFullyConnectedStatesForLabels();
    crf.setWeightsDimensionAsIn(lists[0], false);
    CRFTrainerByStochasticGradient crft = new CRFTrainerByStochasticGradient(
        crf, 0.0001);
View Full Code Here

  }

  public void testTokenAccuracy() {
    Pipe p = makeSpacePredictionPipe();

    InstanceList instances = new InstanceList(p);
    instances.addThruPipe(new ArrayIterator(data));
    InstanceList[] lists = instances.split(new Random(777), new double[] {
        .5, .5 });

    CRF crf = new CRF(p.getDataAlphabet(), p.getTargetAlphabet());
    crf.addFullyConnectedStatesForLabels();
    CRFTrainerByLabelLikelihood crft = new CRFTrainerByLabelLikelihood(crf);
View Full Code Here

    Pipe p = new SerialPipes(new Pipe[] {
        new CharSequence2TokenSequence("."), new TokenText(),
        new TestCRFTokenSequenceRemoveSpaces(),
        new TokenSequence2FeatureVectorSequence(),
        new PrintInputAndTarget(), });
    InstanceList one = new InstanceList(p);
    String[] data = new String[] { "ABCDE", };
    one.addThruPipe(new ArrayIterator(data));
    CRF crf = new CRF(p, null);
    crf.addFullyConnectedStatesForThreeQuarterLabels(one);
    CRFTrainerByLabelLikelihood crft = new CRFTrainerByLabelLikelihood(crf);
    crf.setWeightsDimensionAsIn(one, false);
    Optimizable mcrf = crft.getOptimizableCRF(one);
View Full Code Here

    Pipe p = new SerialPipes(new Pipe[] {
        new CharSequence2TokenSequence("."), new TokenText(),
        new TestCRFTokenSequenceRemoveSpaces(),
        new TokenSequence2FeatureVectorSequence(),
        new PrintInputAndTarget(), });
    InstanceList one = new InstanceList(p);
    String[] data = new String[] { "ABCDE", };
    one.addThruPipe(new ArrayIterator(data));
    CRF crf = new CRF(p, null);
    crf.addFullyConnectedStatesForLabels();
    CRFTrainerByLabelLikelihood crft = new CRFTrainerByLabelLikelihood(crf);
    crf.setWeightsDimensionAsIn(one, false);
    Optimizable.ByGradientValue mcrf = crft.getOptimizableCRF(one);
View Full Code Here

            .compile("^(\\S+) (.*)"), 2, 1),
        new TokenSequenceParseFeatureString(false), new TokenText(),
        new TokenSequence2FeatureVectorSequence(true, false),
        new Target2LabelSequence(), new PrintInputAndTarget(), });

    InstanceList data = new InstanceList(p);
    data.addThruPipe(new LineGroupIterator(new StringReader(toy), Pattern
        .compile("\n"), true));

    CRF crf = new CRF(p, null);
    crf.print();
    crf.addStatesForLabelsConnectedAsIn(data);
View Full Code Here

TOP

Related Classes of cc.mallet.types.InstanceList

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.