Package cc.mallet.types

Examples of cc.mallet.types.FeatureVectorSequence


    double[][] gammas;   
    TIntArrayList cache = new TIntArrayList();
    for (int i = 0; i < lattices.size(); i++) {
      if (lattices.get(i) == null) { continue; }
      SumLattice lattice = lattices.get(i);
      FeatureVectorSequence fvs = (FeatureVectorSequence)lattice.getInput();
      gammas = lattice.getGammas();
      for (int ip = 0; ip < fvs.size(); ++ip) {
        cache.resetQuick();
        FeatureVector fv = fvs.getFeatureVector(ip);
        int fi;
        for (int loc = 0; loc < fv.numLocations(); loc++) {
          fi = fv.indexAtLocation(loc);
          // binary constraint features
          if (constraints.containsKey(fi)) {
View Full Code Here


    int ii = 0;
    int fi;
    FeatureVector fv;
    BitSet bitSet = new BitSet(data.size());
    for (Instance instance : data) {
      FeatureVectorSequence fvs = (FeatureVectorSequence)instance.getData();
      for (int ip = 0; ip < fvs.size(); ip++) {
        fv = fvs.get(ip);
        for (int loc = 0; loc < fv.numLocations(); loc++) {
          fi = fv.indexAtLocation(loc);
          if (constraints.containsKey(fi)) {
            constraints.get(fi).count += 1;
            bitSet.set(ii);
View Full Code Here

  public BitSet preProcess(InstanceList data) {
    // count number of tokens
    BitSet bitSet = new BitSet(data.size());
    bitSet.set(0, data.size(), true);
    for (Instance instance : data) {
      FeatureVectorSequence fvs = (FeatureVectorSequence)instance.getData();
      this.numTokens += fvs.size();
    }
    return bitSet;
  }   
View Full Code Here

    double[][][] xis;
    for (int i = 0; i < lattices.size(); i++) {
      SumLattice lattice = lattices.get(i);
      xis = lattice.getXis();
      int numStates = xis[0].length;
      FeatureVectorSequence fvs = (FeatureVectorSequence)lattice.getInput();
      for (int ip = 0; ip < fvs.size(); ++ip) {
        for (int si = 0; si < numStates; si++) {
          this.expectation += Math.exp(xis[ip][si][si]);
        }
      }
    }
View Full Code Here

  }

  public void cacheDotProducts() {
    cachedDots = new double[trainingSet.size()][][][];
    for (int i = 0; i < trainingSet.size(); i++) {
      FeatureVectorSequence input = (FeatureVectorSequence)trainingSet.get(i).getData();

      cachedDots[i] = new double[input.size()][crf.numStates()][crf.numStates()];
      for (int j = 0; j < input.size(); j++) {
        for (int k = 0; k < crf.numStates(); k++) {
          for (int l = 0; l < crf.numStates(); l++) {
            cachedDots[i][j][k][l] = Transducer.IMPOSSIBLE_WEIGHT;
          }
        }
      }

      for (int j = 0; j < input.size(); j++) {
        for (int k = 0; k < crf.numStates(); k++) {
          TransitionIterator iter = crf.getState(k).transitionIterator(input, j);
          while (iter.hasNext()) {
            int l = iter.next().getIndex();
            cachedDots[i][j][k][l] = iter.getWeight();
View Full Code Here

    int ii = 0;
    int fi;
    FeatureVector fv;
    BitSet bitSet = new BitSet(data.size());
    for (Instance instance : data) {
      FeatureVectorSequence fvs = (FeatureVectorSequence)instance.getData();
      for (int ip = 0; ip < fvs.size(); ip++) {
        fv = fvs.get(ip);
        for (int loc = 0; loc < fv.numLocations(); loc++) {
          fi = fv.indexAtLocation(loc);
          if (constraints.containsKey(fi)) {
            constraints.get(fi).count += 1;
            bitSet.set(ii);
View Full Code Here

    double[][] gammas;   
    TIntArrayList cache = new TIntArrayList();
    for (int i = 0; i < lattices.size(); i++) {
      if (lattices.get(i) == null) { continue; }
      SumLattice lattice = lattices.get(i);
      FeatureVectorSequence fvs = (FeatureVectorSequence)lattice.getInput();
      gammas = lattice.getGammas();
      for (int ip = 0; ip < fvs.size(); ++ip) {
        cache.resetQuick();
        FeatureVector fv = fvs.getFeatureVector(ip);
        int fi;
        for (int loc = 0; loc < fv.numLocations(); loc++) {
          fi = fv.indexAtLocation(loc);
          // binary constraint features
          if (constraints.containsKey(fi)) {
View Full Code Here

    // compute GE gradient
    if (numThreads == 1) {
      for (int ii = 0; ii < data.size(); ii++) {
        if (instancesWithConstraints.get(ii)) {
          SumLattice lattice = lattices.get(ii);
          FeatureVectorSequence fvs = (FeatureVectorSequence)data.get(ii).getData();
          new GELattice(fvs, lattice.getGammas(), lattice.getXis(), crf, reverseTrans, reverseTransIndices, cachedGradient,this.constraints, false);
        }
      }
    }
    else {
View Full Code Here

    String[] stateNames = new String[numStates];
    for (int i = 0; i < numStates; i++)
      stateNames[i] = "state" + i;
    MEMM saveCRF = crf;
    //inputAlphabet = (Feature.Alphabet) crf.getInputAlphabet();
    FeatureVectorSequence fvs = new FeatureVectorSequence(new FeatureVector[]{
      new FeatureVector(crf.getInputAlphabet(), new int[]{1, 2, 3}, new double[]{1, 1, 1}),
      new FeatureVector(crf.getInputAlphabet(), new int[]{1, 2, 3}, new double[]{1, 1, 1}),
      new FeatureVector(crf.getInputAlphabet(), new int[]{1, 2, 3}, new double[]{1, 1, 1}),
      new FeatureVector(crf.getInputAlphabet(), new int[]{1, 2, 3}, new double[]{1, 1, 1}),
    });
View Full Code Here

  public Void call() throws Exception {
    for (int ii = start; ii < end; ii++) {
      if (instancesWithConstraints.get(ii)) {
        SumLattice lattice = lattices.get(ii);
        FeatureVectorSequence fvs = (FeatureVectorSequence)data.get(ii).getData();
        new GELattice(fvs, lattice.getGammas(), lattice.getXis(),
          crf, reverseTrans, reverseTransIndices, gradient,this.constraints, false);
      }
    }
    return null;
View Full Code Here

TOP

Related Classes of cc.mallet.types.FeatureVectorSequence

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.