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


Java MatrixOps.rowDotProduct方法代码示例

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


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

示例1: getUnnormalizedClassificationScores

import cc.mallet.types.MatrixOps; //导入方法依赖的package包/类
public void getUnnormalizedClassificationScores (Instance instance, double[] scores)
{
 //  arrayOutOfBounds if pipe has grown since training 
 //        int numFeatures = getAlphabet().size() + 1;
    int numFeatures = this.defaultFeatureIndex + 1;

    int numLabels = getLabelAlphabet().size();
    assert (scores.length == numLabels);
    FeatureVector fv = (FeatureVector) instance.getData ();
    // Make sure the feature vector's feature dictionary matches
    // what we are expecting from our data pipe (and thus our notion
    // of feature probabilities.
    assert (fv.getAlphabet ()
            == this.instancePipe.getDataAlphabet ());

    // Include the feature weights according to each label
    for (int li = 0; li < numLabels; li++) {
        scores[li] = parameters[li*numFeatures + defaultFeatureIndex]
                + MatrixOps.rowDotProduct (parameters, numFeatures,
                        li, fv,
                        defaultFeatureIndex,
                        (perClassFeatureSelection == null
                ? featureSelection
                : perClassFeatureSelection[li]));
    }
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:27,代码来源:MCMaxEnt.java

示例2: getUnnormalizedClassificationScores

import cc.mallet.types.MatrixOps; //导入方法依赖的package包/类
public void getUnnormalizedClassificationScores (Instance instance, double[] scores)
{
	//  arrayOutOfBounds if pipe has grown since training
	//        int numFeatures = getAlphabet().size() + 1;
	int numFeatures = this.defaultFeatureIndex + 1;

	int numLabels = getLabelAlphabet().size();
	assert (scores.length == numLabels);
	FeatureVector fv = (FeatureVector) instance.getData ();
	// Make sure the feature vector's feature dictionary matches
	// what we are expecting from our data pipe (and thus our notion
	// of feature probabilities.
	assert (fv.getAlphabet ()
			== this.instancePipe.getDataAlphabet ());

	// Include the feature weights according to each label
	for (int li = 0; li < numLabels; li++) {
		scores[li] = parameters[li*numFeatures + defaultFeatureIndex]
		                        + MatrixOps.rowDotProduct (parameters, numFeatures,
		                        		li, fv,
		                        		defaultFeatureIndex,
		                        		(perClassFeatureSelection == null
		                        				? featureSelection
		                        						: perClassFeatureSelection[li]));
	}
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:27,代码来源:MaxEnt.java

示例3: getClassificationScores

import cc.mallet.types.MatrixOps; //导入方法依赖的package包/类
public void getClassificationScores (Instance instance, double[] scores)
{
    int numLabels = getLabelAlphabet().size();
    assert (scores.length == numLabels);
    FeatureVector fv = (FeatureVector) instance.getData ();
    // Make sure the feature vector's feature dictionary matches
    // what we are expecting from our data pipe (and thus our notion
    // of feature probabilities.
    assert (instancePipe == null || fv.getAlphabet () == this.instancePipe.getDataAlphabet ());
 //  arrayOutOfBounds if pipe has grown since training 
 //        int numFeatures = getAlphabet().size() + 1;
    int numFeatures = this.defaultFeatureIndex + 1;

    // Include the feature weights according to each label
    for (int li = 0; li < numLabels; li++) {
        scores[li] = parameters[li*numFeatures + defaultFeatureIndex]
                + MatrixOps.rowDotProduct (parameters, numFeatures,
                        li, fv,
                        defaultFeatureIndex,
                        (perClassFeatureSelection == null
                ? featureSelection
                : perClassFeatureSelection[li]));
        // xxxNaN assert (!Double.isNaN(scores[li])) : "li="+li;
    }

    // Move scores to a range where exp() is accurate, and normalize
    double max = MatrixOps.max (scores);
    double sum = 0;
    for (int li = 0; li < numLabels; li++)
        sum += (scores[li] = Math.exp (scores[li] - max));
    for (int li = 0; li < numLabels; li++) {
        scores[li] /= sum;
        // xxxNaN assert (!Double.isNaN(scores[li]));
    }
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:36,代码来源:MCMaxEnt.java

示例4: getUnnormalizedClassificationScores

import cc.mallet.types.MatrixOps; //导入方法依赖的package包/类
/** returns unnormalized scores, corresponding to the score an
 * element of the InstanceList being the "top" instance
 * @param instance instance with data field a {@link InstanceList}.
 * @param scores has length = number of Instances in Instance.data,
 * which is of type InstanceList */
public void getUnnormalizedClassificationScores (Instance instance, double[] scores)
{
	FeatureVectorSequence fvs = (FeatureVectorSequence)instance.getData();
	assert (scores.length == fvs.size());
	int numFeatures = instance.getDataAlphabet().size()+1;

	for (int instanceNumber=0; instanceNumber < fvs.size(); instanceNumber++) {
		FeatureVector fv = (FeatureVector)fvs.get(instanceNumber);
		// Make sure the feature vector's feature dictionary matches
		// what we are expecting from our data pipe (and thus our notion
		// of feature probabilities.
		assert (fv.getAlphabet ()
						== this.instancePipe.getDataAlphabet ());
		
		// Include the feature weights according to each label xxx is
		// this correct ? we only calculate the dot prod of the feature
		// vector with the "positiveLabel" weights
		// xxx include multiple labels
		scores[instanceNumber] = parameters[0*numFeatures + defaultFeatureIndex]
															 + MatrixOps.rowDotProduct (parameters, numFeatures,
																													0, fv,
																													defaultFeatureIndex,
																													(perClassFeatureSelection == null
																													 ? featureSelection
																													 : perClassFeatureSelection[0]));
	}
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:33,代码来源:RankMaxEnt.java

示例5: getClassificationScores

import cc.mallet.types.MatrixOps; //导入方法依赖的package包/类
public void getClassificationScores (Instance instance, double[] scores)
{
	FeatureVectorSequence fvs = (FeatureVectorSequence)instance.getData();
	int numFeatures = instance.getDataAlphabet().size()+1;
	int numLabels = fvs.size();
	assert (scores.length == fvs.size());

	for (int instanceNumber=0; instanceNumber < fvs.size(); instanceNumber++) {
		FeatureVector fv = (FeatureVector)fvs.get(instanceNumber);
		// Make sure the feature vector's feature dictionary matches
		// what we are expecting from our data pipe (and thus our notion
		// of feature probabilities.
		assert (fv.getAlphabet ()
						== this.instancePipe.getDataAlphabet ());
		
		// Include the feature weights according to each label
		scores[instanceNumber] = parameters[0*numFeatures + defaultFeatureIndex]
															 + MatrixOps.rowDotProduct (parameters, numFeatures,
																													0, fv,
																													defaultFeatureIndex,
																													(perClassFeatureSelection == null
																													 ? featureSelection
																													 : perClassFeatureSelection[0]));
	}

	// Move scores to a range where exp() is accurate, and normalize
	double max = MatrixOps.max (scores);
	double sum = 0;
	for (int li = 0; li < numLabels; li++)
		sum += (scores[li] = Math.exp (scores[li] - max));
	for (int li = 0; li < numLabels; li++) {
		scores[li] /= sum;
		// xxxNaN assert (!Double.isNaN(scores[li]));
	}
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:36,代码来源:RankMaxEnt.java

示例6: getUnnormalizedClassificationScores

import cc.mallet.types.MatrixOps; //导入方法依赖的package包/类
/** returns unnormalized scores, corresponding to the score an
 * element of the InstanceList being the "top" instance
 * @param instance instance with data field a {@link cc.mallet.types.InstanceList}.
 * @param scores has length = number of Instances in Instance.data,
 * which is of type InstanceList */
public void getUnnormalizedClassificationScores (Instance instance, double[] scores)
{
	FeatureVectorSequence fvs = (FeatureVectorSequence)instance.getData();
	assert (scores.length == fvs.size());
	int numFeatures = instance.getDataAlphabet().size()+1;

	for (int instanceNumber=0; instanceNumber < fvs.size(); instanceNumber++) {
		FeatureVector fv = (FeatureVector)fvs.get(instanceNumber);
		// Make sure the feature vector's feature dictionary matches
		// what we are expecting from our data pipe (and thus our notion
		// of feature probabilities.
		assert (fv.getAlphabet ()
						== this.instancePipe.getDataAlphabet ());
		
		// Include the feature weights according to each label xxx is
		// this correct ? we only calculate the dot prod of the feature
		// vector with the "positiveLabel" weights
		// xxx include multiple labels
		scores[instanceNumber] = parameters[0*numFeatures + defaultFeatureIndex]
															 + MatrixOps.rowDotProduct (parameters, numFeatures,
																													0, fv,
																													defaultFeatureIndex,
																													(perClassFeatureSelection == null
																													 ? featureSelection
																													 : perClassFeatureSelection[0]));
	}
}
 
开发者ID:shalomeir,项目名称:tctm,代码行数:33,代码来源:RankMaxEnt.java


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