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


Java Flops类代码示例

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


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

示例1: divideByInternal

import cc.mallet.grmm.util.Flops; //导入依赖的package包/类
protected void divideByInternal (DiscreteFactor ptl)
{
  int[] projection = largeIdxToSmall (ptl);
  int numLocs = probs.numLocations ();
  for (int singleLoc = 0; singleLoc < numLocs; singleLoc++) {
    int smallIdx = projection[singleLoc];
    double prev = this.probs.valueAtLocation (singleLoc);
    double newVal = ptl.logValue (smallIdx);
    double product = prev - newVal;
    /* by convention, let -Inf + Inf (corresponds to 0/0) be -Inf */
    if (Double.isInfinite (newVal)) {
      product = Double.NEGATIVE_INFINITY;
    }
    this.probs.setValueAtLocation (singleLoc, product);
  }
  Flops.increment (numLocs);  // handle the pluses
}
 
开发者ID:mimno,项目名称:GRMM,代码行数:18,代码来源:LogTableFactor.java

示例2: marginalizeInternal

import cc.mallet.grmm.util.Flops; //导入依赖的package包/类
protected Factor marginalizeInternal (AbstractTableFactor result)
  {

    result.setAll (Double.NEGATIVE_INFINITY);
    int[] projection = largeIdxToSmall (result);

    /* Add each element of the single array of the large potential
to the correct element in the small potential. */
    int numLocs = probs.numLocations ();
    for (int largeLoc = 0; largeLoc < numLocs; largeLoc++) {

      /* Convert a single-index from this distribution to
 one for the smaller distribution */
      int smallIdx = projection[largeLoc];

      /* Whew! Now, add it in. */
      double oldValue = this.probs.valueAtLocation (largeLoc);
      double currentValue = result.probs.singleValue (smallIdx);
      result.probs.setValueAtLocation (smallIdx,
              Maths.sumLogProb (oldValue, currentValue));

    }
    Flops.sumLogProb (numLocs);

    return result;
  }
 
开发者ID:mimno,项目名称:GRMM,代码行数:27,代码来源:LogTableFactor.java

示例3: marginalizeInternal

import cc.mallet.grmm.util.Flops; //导入依赖的package包/类
protected Factor marginalizeInternal (AbstractTableFactor result)
  {

    result.setAll (0.0);

    int[] projection = largeIdxToSmall (result);

    /* Add each element of the single array of the large potential
to the correct element in the small potential. */
    int numLocs = probs.numLocations ();
    for (int largeLoc = 0; largeLoc < numLocs; largeLoc++) {

      /* Convert a single-index from this distribution to
 one for the smaller distribution */
      int smallIdx = projection[largeLoc];

      /* Whew! Now, add it in. */
      double oldValue = this.probs.valueAtLocation (largeLoc);
      result.probs.incrementSingleValue (smallIdx, oldValue);
    }

    Flops.increment (numLocs);

    return result;
  }
 
开发者ID:mimno,项目名称:GRMM,代码行数:26,代码来源:TableFactor.java

示例4: divideByInternal

import cc.mallet.grmm.util.Flops; //导入依赖的package包/类
protected void divideByInternal (DiscreteFactor ptl)
{
  int[] projection = largeIdxToSmall (ptl);
  int numLocs = probs.numLocations ();
  for (int singleLoc = 0; singleLoc < numLocs; singleLoc++) {
    int smallIdx = projection[singleLoc];
    double prev = this.probs.valueAtLocation (singleLoc);
    double newVal = ptl.value (smallIdx);
    double product = prev / newVal;
    /* by convention, let dividing by zero just return 0 */
    if (Maths.almostEquals (newVal, 0)) {
      product = 0;
    }
    this.probs.setValueAtLocation (singleLoc, product);
  }
  Flops.increment (numLocs);
}
 
开发者ID:mimno,项目名称:GRMM,代码行数:18,代码来源:TableFactor.java

示例5: logspaceOneNorm

import cc.mallet.grmm.util.Flops; //导入依赖的package包/类
private double logspaceOneNorm ()
{
  double sum = Double.NEGATIVE_INFINITY; // That's 0 in log space
  for (int i = 0; i < probs.numLocations (); i++) {
    sum = Maths.sumLogProb (sum, probs.valueAtLocation (i));
  }
  Flops.sumLogProb (probs.numLocations ());
  return sum;
}
 
开发者ID:mimno,项目名称:GRMM,代码行数:10,代码来源:LogTableFactor.java

示例6: multiplyByInternal

import cc.mallet.grmm.util.Flops; //导入依赖的package包/类
/**
 * Does the conceptual equivalent of this *= pot.
 * Assumes that pot's variables are a subset of
 * this potential's.
 */
protected void multiplyByInternal (DiscreteFactor ptl)
{
  int[] projection = largeIdxToSmall (ptl);
  int numLocs = probs.numLocations ();
  for (int singleLoc = 0; singleLoc < numLocs; singleLoc++) {
    int smallIdx = projection[singleLoc];
    double prev = this.probs.valueAtLocation (singleLoc);
    double newVal = ptl.logValue (smallIdx);
    double product = prev + newVal;
    this.probs.setValueAtLocation (singleLoc, product);
  }
  Flops.increment (numLocs);  // handle the pluses
}
 
开发者ID:mimno,项目名称:GRMM,代码行数:19,代码来源:LogTableFactor.java

示例7: plusEqualsInternal

import cc.mallet.grmm.util.Flops; //导入依赖的package包/类
/**
 * Does the conceptual equivalent of this += pot.
 * Assumes that pot's variables are a subset of
 * this potential's.
 */
protected void plusEqualsInternal (DiscreteFactor ptl)
{
  int[] projection = largeIdxToSmall (ptl);
  int numLocs = probs.numLocations ();
  for (int singleLoc = 0; singleLoc < numLocs; singleLoc++) {
    int smallIdx = projection[singleLoc];
    double prev = this.probs.valueAtLocation (singleLoc);
    double newVal = ptl.logValue (smallIdx);
    double product = Maths.sumLogProb (prev, newVal);
    this.probs.setValueAtLocation (singleLoc, product);
  }
  Flops.sumLogProb (numLocs);
}
 
开发者ID:mimno,项目名称:GRMM,代码行数:19,代码来源:LogTableFactor.java

示例8: setValues

import cc.mallet.grmm.util.Flops; //导入依赖的package包/类
public void setValues (double[] vals)
{
  Flops.log (vals.length);
  for (int i = 0; i < vals.length; i++) {
    setRawValue (i, Math.log (vals[i]));
  }
}
 
开发者ID:mimno,项目名称:GRMM,代码行数:8,代码来源:LogTableFactor.java

示例9: timesEqualsLog

import cc.mallet.grmm.util.Flops; //导入依赖的package包/类
private void timesEqualsLog (double logV)
{
  Flops.increment (probs.numLocations ());
  Matrix other = (Matrix) probs.cloneMatrix ();
  other.setAll (logV);
  probs.plusEquals (other);
}
 
开发者ID:mimno,项目名称:GRMM,代码行数:8,代码来源:LogTableFactor.java

示例10: makeFromMatrix

import cc.mallet.grmm.util.Flops; //导入依赖的package包/类
public static LogTableFactor makeFromMatrix (Variable[] vars, SparseMatrixn values)
{
  SparseMatrixn logValues = (SparseMatrixn) values.cloneMatrix ();
  for (int i = 0; i < logValues.numLocations (); i++) {
    logValues.setValueAtLocation (i, Math.log (logValues.valueAtLocation (i)));
  }
  Flops.log (logValues.numLocations ());
  return new LogTableFactor (vars, logValues);
}
 
开发者ID:mimno,项目名称:GRMM,代码行数:10,代码来源:LogTableFactor.java

示例11: getValueMatrix

import cc.mallet.grmm.util.Flops; //导入依赖的package包/类
public Matrix getValueMatrix ()
{
  Matrix logProbs = (Matrix) probs.cloneMatrix ();
  for (int loc = 0; loc < probs.numLocations (); loc++) {
    logProbs.setValueAtLocation (loc, Math.exp (logProbs.valueAtLocation (loc)));
  }
  Flops.exp (probs.numLocations ());
  return logProbs;
}
 
开发者ID:mimno,项目名称:GRMM,代码行数:10,代码来源:LogTableFactor.java

示例12: normalize

import cc.mallet.grmm.util.Flops; //导入依赖的package包/类
/**
 * Multiplies every entry in the potential by a constant
 * such that all the entries sum to 1.
 */
public Factor normalize ()
{
  Flops.increment (2 * probs.numLocations ());
  probs.oneNormalize ();
  return this;
}
 
开发者ID:mimno,项目名称:GRMM,代码行数:11,代码来源:TableFactor.java


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