Examples of TObjectDoubleIterator


Examples of gnu.trove.TObjectDoubleIterator

    int totalEdges = 0;
    double totalDistance = 0;

    for (String vName : this._vertices.keySet()) {
      Vertex2 v = this._vertices.get(vName);
      TObjectDoubleIterator nIter = v.GetNeighbors().iterator();
      while (nIter.hasNext()) {
        nIter.advance();
        ++totalEdges;

        // we assume that the currently set distances are distance squares,
        // so we need to take sqrt before averaging.
        totalDistance += Math.sqrt(v.GetNeighborWeight((String) nIter.key()));
     
    }

    return ((1.0 * totalDistance) / totalEdges);
  }
View Full Code Here

Examples of gnu.trove.TObjectDoubleIterator

    Iterator<String> viter0 = this._vertices.keySet().iterator();
    while (viter0.hasNext()) {
      String vName = viter0.next();
      Vertex2 v = _vertices.get(vName);
      if (v.IsSeedNode()) {
        TObjectDoubleIterator injLabIter =
            this._labelManager.getLabelScores(v.GetInjectedLabelScores()).iterator();
        while (injLabIter.hasNext()) {
          injLabIter.advance();
          double currVal = classSeedSum.containsKey(injLabIter.key()) ?
            classSeedSum.get(injLabIter.key()) : 0;
          classSeedSum.put(injLabIter.key(), currVal + injLabIter.value());
         
          // add the label to the list of labels
          if (!labels.containsKey(injLabIter.key())) {
            labels.put(injLabIter.key(), 1.0);
          }
        }
      }
    }
   
    double[] seedWeightSums = classSeedSum.getValues();
    double maxSum = -1;
    for (int wsi = 0; wsi < seedWeightSums.length; ++wsi) {
      if (seedWeightSums[wsi] > maxSum) {
        maxSum = seedWeightSums[wsi];
      }
    }
   
    TObjectDoubleHashMap seedAmpliFactor = new TObjectDoubleHashMap();
    TObjectDoubleIterator wIter = classSeedSum.iterator();
    while (wIter.hasNext()) {
      wIter.advance();
      seedAmpliFactor.put(wIter.key(), maxSum / wIter.value());
      System.out.println("Label: " + wIter.key() +
                         " ampli_factor: " + seedAmpliFactor.get(wIter.key()));
    }
   
    // now multiply injected scores with amplification factors
    Iterator<String> viter = this._vertices.keySet().iterator();
    while (viter.hasNext()) {
      String vName = viter.next();
      Vertex2 v = _vertices.get(vName);
      if (v.IsSeedNode()) {       
        TObjectDoubleIterator injLabIter =
            this._labelManager.getLabelScores(v.GetInjectedLabelScores()).iterator();
        while (injLabIter.hasNext()) {
          injLabIter.advance();
         
          double currVal = injLabIter.value();
          injLabIter.setValue(currVal * seedAmpliFactor.get(injLabIter.key()));
        }
      }
    }
  }
View Full Code Here

Examples of gnu.trove.TObjectDoubleIterator

  // initialize estimated scores with uniform scores for all labels
  public void SetEstimatedScoresToUniformLabelPrior(Vertex2 v) {
    Random r = new Random(1000);

    TObjectDoubleIterator lIter = _labels.iterator();
    double perLabScore = 1.0 / _labels.size();

    while (lIter.hasNext()) {
      lIter.advance();
      // v.SetEstimatedLabelScore((String) lIter.key(), perLabScore);
     
      // (sparse) random initialization
      if (r.nextBoolean()) {
        v.SetEstimatedLabelScore((String) lIter.key(), r.nextFloat());
      }
    }
  }
View Full Code Here

Examples of gnu.trove.iterator.TObjectDoubleIterator

        TObjectDoubleMap that = ( TObjectDoubleMap ) other;
        if ( that.size() != this.size() ) {
            return false;
        }
        try {
            TObjectDoubleIterator iter = this.iterator();
            while ( iter.hasNext() ) {
                iter.advance();
                Object key = iter.key();
                double value = iter.value();
                if ( value == no_entry_value ) {
                    if ( !( that.get( key ) == that.getNoEntryValue() &&
                      that.containsKey( key ) ) ) {

                        return false;
View Full Code Here

Examples of gnu.trove.iterator.TObjectDoubleIterator

        TObjectDoubleMap that = ( TObjectDoubleMap ) other;
        if ( that.size() != this.size() ) {
            return false;
        }
        try {
            TObjectDoubleIterator iter = this.iterator();
            while ( iter.hasNext() ) {
                iter.advance();
                Object key = iter.key();
                double value = iter.value();
                if ( value == no_entry_value ) {
                    if ( !( that.get( key ) == that.getNoEntryValue() &&
                      that.containsKey( key ) ) ) {

                        return false;
View Full Code Here

Examples of gnu.trove.iterator.TObjectDoubleIterator

        TObjectDoubleMap that = ( TObjectDoubleMap ) other;
        if ( that.size() != this.size() ) {
            return false;
        }
        try {
            TObjectDoubleIterator iter = this.iterator();
            while ( iter.hasNext() ) {
                iter.advance();
                Object key = iter.key();
                double value = iter.value();
                if ( value == no_entry_value ) {
                    if ( !( that.get( key ) == that.getNoEntryValue() &&
                      that.containsKey( key ) ) ) {

                        return false;
View Full Code Here

Examples of gnu.trove.iterator.TObjectDoubleIterator

        TObjectDoubleMap that = ( TObjectDoubleMap ) other;
        if ( that.size() != this.size() ) {
            return false;
        }
        try {
            TObjectDoubleIterator iter = this.iterator();
            while ( iter.hasNext() ) {
                iter.advance();
                Object key = iter.key();
                double value = iter.value();
                if ( value == no_entry_value ) {
                    if ( !( that.get( key ) == that.getNoEntryValue() &&
                      that.containsKey( key ) ) ) {

                        return false;
View Full Code Here

Examples of gnu.trove.iterator.TObjectDoubleIterator

       //
       // message to self
       output.collect(new Text(fields[0]), new Text(line));

       // message to neighbors
       TObjectDoubleIterator neighIterator = neighbors.iterator();
       while (neighIterator.hasNext()) {
         neighIterator.advance();
        
         // message (neighbor_node, current_node + DELIM + curr_node_label_scores
         output.collect(new Text((String) neighIterator.key()),
                   new Text(fields[0] + _kDelim + fields[3]));
       }
     }
View Full Code Here

Examples of gnu.trove.iterator.TObjectDoubleIterator

      if (vi < totalTrainInstances) {
        v.setIsSeedNode(true);
       
        // we expect that the gold labels for the node has already been
        // set, we only need to copy them as injected labels
        TObjectDoubleIterator goldLabIter = v.goldLabels().iterator();
        while (goldLabIter.hasNext()) {
          goldLabIter.advance();
          v.SetInjectedLabelScore((String) goldLabIter.key(), goldLabIter.value());
        }
      } else {
        v.setIsTestNode(true);
      }
    }
View Full Code Here

Examples of gnu.trove.iterator.TObjectDoubleIterator

       //
       // message to self
       output.collect(new Text(fields[0]), new Text(line));

       // message to neighbors
       TObjectDoubleIterator neighIterator = neighbors.iterator();
       while (neighIterator.hasNext()) {
         neighIterator.advance();
        
         // message (neighbor_node, current_node + DELIM + curr_node_label_scores
         output.collect(new Text((String) neighIterator.key()),
                   new Text(fields[0] + _kDelim + fields[3]));
       }
     }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.