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


Java MatrixOps.normalize方法代码示例

本文整理汇总了Java中cc.mallet.types.MatrixOps.normalize方法的典型用法代码示例。如果您正苦于以下问题:Java MatrixOps.normalize方法的具体用法?Java MatrixOps.normalize怎么用?Java MatrixOps.normalize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cc.mallet.types.MatrixOps的用法示例。


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

示例1: toProbabilities

import cc.mallet.types.MatrixOps; //导入方法依赖的package包/类
private double[] toProbabilities(double weights[]) {
  double probs[] = new double[weights.length];
  for (int i = 0; i < weights.length; i++)
    probs[i] = Math.exp(weights[i]);
  // TODO this shouldn't be necessary
  MatrixOps.normalize(probs);
  return probs;
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:9,代码来源:CRFOptimizableByKL.java

示例2: split

import cc.mallet.types.MatrixOps; //导入方法依赖的package包/类
/**
 * Shuffles the elements of this list among several smaller
 * lists. Overrides InstanceList.split to add instances in original
 * order, to prevent thrashing.
 * @param proportions A list of numbers (not necessarily summing to 1) which,
 * when normalized, correspond to the proportion of elements in each returned
 * sublist.
 * @param r The source of randomness to use in shuffling.
 * @return one <code>InstanceList</code> for each element of <code>proportions</code>
 */
public InstanceList[] split (java.util.Random r, double[] proportions) {
    InstanceList[] ret = new InstanceList[proportions.length];
    double maxind[] = proportions.clone();
    int size = size();
    int[] shuffled = new int[size];
    int[] splits = new int[size];

    // build a list of shuffled instance indexes
    for (int i = 0; i < size; i++) {
        shuffled[i] = i;
    }
    shuffleArray(r, shuffled);

    MatrixOps.normalize(maxind);
    for (int i = 0; i < maxind.length; i++) {
        ret[i] = this.cloneEmpty();  // Note that we are passing on featureSelection here.
        if (i > 0) 
            maxind[i] += maxind[i-1];
    }
    for (int i = 0; i < maxind.length; i++) { 
        // Fill maxind[] with the highest instance index to go in each corresponding returned InstanceList
        maxind[i] = Math.rint (maxind[i] * size);
    }
    for (int i = 0, j = 0; i < size; i++) {
        // This gives a slight bias toward putting an extra instance in the last InstanceList.
        while (i >= maxind[j] && j < ret.length) 
            j++;
        splits[shuffled[i]] = j;
    }

    for (int i = 0; i < size; i++) {
        //logger.info ("adding instance " + i + " to split ilist " + splits[i]);
        ret[splits[i]].add(this.get(i));
    }

    return ret;
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:48,代码来源:PagedInstanceList.java


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