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


Java DenseVector.size方法代码示例

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


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

示例1: procResults

import no.uib.cipr.matrix.DenseVector; //导入方法依赖的package包/类
@Override
void procResults(String queryID, Map<String, String> docFields, 
                 CandidateEntry[] scoredDocs, int numRet, Map<String, DenseVector> docFeats)
    throws IOException {
  BufferedWriter featOut = mhOutFiles.get(numRet);
  if (null == featOut) 
    throw new RuntimeException("Bug, output file is not init. for numRet=" + numRet);

  for (CandidateEntry e : scoredDocs) {
    String label = e.mIsRelev ? "1" : "0";
    String docId = e.mDocId;
    DenseVector vect = docFeats.get(docId);
    
    StringBuffer sb = new StringBuffer();
    
    sb.append(label + " ");
    sb.append("qid:" + queryID);
    
    for (int fn = 0; fn < vect.size(); ++fn)
      // Note that feature numbers should start from 1 or else some libraries like RankLib will not work correctly!
      sb.append(" " + (fn+1) + ":" + vect.get(fn));
    
    featOut.write(sb.toString());
    featOut.newLine();
  }
}
 
开发者ID:oaqa,项目名称:knn4qa,代码行数:27,代码来源:GenFeaturesAppMultThread.java

示例2: DenseDoubleVector

import no.uib.cipr.matrix.DenseVector; //导入方法依赖的package包/类
/**
 * Creates a new dense vector with the given size and paste for each entry the given value.
 *
 * @param size the size of the dense vector
 * @param value the value for each entry
 */
public DenseDoubleVector(int size, double value) {
   internalVector = new DenseVector(size);
   for (int index = 0; index < internalVector.size(); index++) {
      internalVector.set(index, value);
   }
}
 
开发者ID:Intelligent-Systems-Group,项目名称:jpl-framework,代码行数:13,代码来源:DenseDoubleVector.java

示例3: addScoresAndRanks

import no.uib.cipr.matrix.DenseVector; //导入方法依赖的package包/类
/**
 * Adds ranks and scores obtained from a candidate provider.
 * 
 * @param docFeats        all features
 * @param resultsAll      result entries
 */
private void addScoresAndRanks(Map<String, DenseVector>   docFeats, 
                               CandidateEntry[]           resultsAll) {
  for (CandidateEntry  e: resultsAll) {
    DenseVector oldVect = docFeats.get(e.mDocId);
    int oldSize = oldVect.size();
    DenseVector newVect = new DenseVector(oldSize + 2);
    newVect.set(0, e.mOrigRank);
    newVect.set(1, e.mOrigScore);
    for (int vi = 0; vi < oldSize; ++vi)
      newVect.set(vi + 2, oldVect.get(vi)); 
    docFeats.replace(e.mDocId, newVect);
  }    
  
}
 
开发者ID:oaqa,项目名称:knn4qa,代码行数:21,代码来源:BaseQueryApp.java

示例4: procResults

import no.uib.cipr.matrix.DenseVector; //导入方法依赖的package包/类
@Override
void procResults(String queryID, Map<String, String> docFields, 
                 CandidateEntry[] scoredDocs, int numRet, Map<String, DenseVector> docFeats) throws Exception {
  String queryObjStr = null;

  queryObjStr = mQueryGen.getStrObjForKNNService(docFields);

  logger.info("KNN Query string:");
  logger.info(queryObjStr);
  logger.info("==========================");

  for (CandidateEntry r : scoredDocs) {
    DenseVector feat = docFeats.get(r.mDocId);
    r.mScore = (float) feat.dot(mModelInterm);

    String docObjStr = mQueryGen.getStrObjForKNNService(r.mDocId);

    // Left queries
    double knnScore = -mKnnServiceClient.getDistance(docObjStr, queryObjStr);
    logger.info(String.format("docId=%s score=%f knn-Service dist=%f",
                              r.mDocId, r.mScore, knnScore));
    DenseVector v = docFeats.get(r.mDocId);
    for (int i = 0; i < v.size(); ++i) {
      if (i > 0) System.out.print(" ");
      System.out.print((i+1) + ":" + v.get(i));
    }
    System.out.println();

    String s1 = cutExtraDigits(r.mScore, MAX_DIGITS_TO_COMPARE);
    String s2 = cutExtraDigits(knnScore, MAX_DIGITS_TO_COMPARE);
    
    mQtyComp++;
    if (!compareApprox(r.mScore, knnScore, MAX_DIGITS_TO_COMPARE)) {
      mQtyPotentMismatch++;
      logger.info("Potential score mismatch!: " + s1 + " (Java) vs " + s2 + " (NMSLIB)");
    }   
  }
}
 
开发者ID:oaqa,项目名称:knn4qa,代码行数:39,代码来源:DebugKNNService.java

示例5: saveFeatureWeights

import no.uib.cipr.matrix.DenseVector; //导入方法依赖的package包/类
/**
 * Saves features (in the form of a sparse vector) to a file.
 * 
 * @param vect        feature weights to save
 * @param fileName    an output file
 */
public static void saveFeatureWeights(DenseVector vect, String fileName) throws IOException {    
  BufferedWriter outFile = new BufferedWriter(new FileWriter(new File(fileName)));
  StringBuffer sb = new StringBuffer();
     
  for (int i = 0; i < vect.size(); ++i)
    sb.append((i+1) + ":" + vect.get(i) + " ");
  
  outFile.write(sb.toString() + System.getProperty("line.separator"));
       
  outFile.close();    
}
 
开发者ID:oaqa,项目名称:knn4qa,代码行数:18,代码来源:FeatureExtractor.java

示例6: saveEventFromCommunity

import no.uib.cipr.matrix.DenseVector; //导入方法依赖的package包/类
public void saveEventFromCommunity(Community c){
    DenseVector nodesC = c.getVertexIndexes();
    if(nodesC.size() > 1){
        EDCoWEvent event = new EDCoWEvent();
        for(VectorEntry ve : nodesC){
            int id = (int)ve.get();
            String keyword = nodeList.get(id).getName();
            event.keywords.add(keyword);
        }
        event.setEpsylon(computeE(c));
        event.setStartSlice(startSlice);
        event.setEndSlice(endSlice);
        events.add(event);
    }
}
 
开发者ID:AdrienGuille,项目名称:SONDY,代码行数:16,代码来源:EDCoWModularityDetection.java

示例7: assign

import no.uib.cipr.matrix.DenseVector; //导入方法依赖的package包/类
void assign(DenseVector feat) {
  mFeatValues = new float[feat.size() + 1];
  double data[] = feat.getData();
  for (int i = 0; i < feat.size(); ++i)
    mFeatValues[i+1] = (float)data[i];
}
 
开发者ID:oaqa,项目名称:knn4qa,代码行数:7,代码来源:BaseQueryApp.java

示例8: updateGammaWithCovariates

import no.uib.cipr.matrix.DenseVector; //导入方法依赖的package包/类
@Override
protected void updateGammaWithCovariates(DenseVector currentGamma) {

    // Handle betaParameter / designMatrix

    if (NEW_APPROACH) {

        final int N = currentGamma.size();
        double[] update = new double[N];

        if (dMatrix != null) {
            final int K = dMatrix.getColumnDimension();

            if (N != dMatrix.getRowDimension()) {
                throw new RuntimeException("Incorrect covariate dimensions (" + N + " != "
                        + dMatrix.getRowDimension() + ")");
            }

            for (int i = 0; i < N; ++i) {
                for (int j = 0; j < K; ++j) {
                    update[i] += dMatrix.getParameterValue(i, j) * betaParameter.getParameterValue(j);
                }
            }
        }

        if (covariates != null) {
            if (beta.size() != covariates.size()) {
                throw new RuntimeException("beta.size() != covariates.size()");
            }

            for (int k = 0; k < beta.size(); ++k) {

                Parameter b = beta.get(k);
                final int J = b.getDimension();
                MatrixParameter covariate = covariates.get(k);

                if ((J != covariate.getRowDimension()) ||
                        (N != covariate.getColumnDimension())) { // Note: XML current has covariates transposed
                    throw new RuntimeException("Incorrect dimensions in " + covariate.getId());
                }

                for (int i = 0; i < N; ++i) {
                    for (int j = 0; j < J; ++j) {
                        update[i] += covariate.getParameterValue(j, i) * b.getParameterValue(j);
                    }
                }
            }
        }

        for (int i = 0; i < N; ++i) {
            currentGamma.set(i, currentGamma.get(i) - update[i]);
        }

    } else {
        DenseVector currentBeta = new DenseVector(beta.size());

        for (int i = 0; i < beta.size(); i++) {
            currentBeta.set(i, beta.get(i).getParameterValue(0));
        }

        //int numMissing = fieldLength - lastObservedIndex;
        //DenseVector tempVectCov = new DenseVector(numMissing);

        //System.err.println("covariates.size(): " + covariates.size());
        //System.err.println("covariates.get(0).getColumnDimension: " + covariates.get(0).getColumnDimension());
        //System.err.println("covariates.get(0).getRowDimension: " + covariates.get(0).getRowDimension());

        for (int i = 0; i < covariates.size(); i++) {
            for (int j = 0; j < covariates.get(i).getColumnDimension(); j++) {
                // System.err.println("j: " + j);
                // System.err.println("covariates.get(i).getParameterValue(0,j): " + covariates.get(i).getParameterValue(0,j));
                currentGamma.set(j, currentGamma.get(j) - covariates.get(i).getParameterValue(0, j) * currentBeta.get(i));
            }
        }
    }
}
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:77,代码来源:GMRFMultilocusSkyrideLikelihood.java


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