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


Java DoubleMatrix.zeros方法代码示例

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


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

示例1: computeQ

import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
protected DoubleMatrix computeQ(DoubleMatrix Y, DoubleMatrix F, DoubleMatrix G, DoubleMatrix Coef) {    	
  	DoubleMatrix Q = DoubleMatrix.zeros(numStates,numStates);
 	
  	double rateOutByBirth, rateOutByMigration, totalRate;
for (int k = 0; k < numStates; k++) /* k row */
{
	double colSum = 0.0, diag;
	if (Y.get(k) > 0) {
		for (int l = 0; l < numStates; l++) 
		{				
			rateOutByBirth = F.get(l,k) * Coef.get(l) / Y.get(k);
			//rateOutByBirth = F.get(l,k)  / Y.get(k);
			rateOutByMigration = G.get(l,k) / (Y.get(k));
			totalRate = rateOutByBirth + rateOutByMigration;
			Q.put(k, l, totalRate);
			colSum += totalRate;				
			
		}
		diag = Q.get(k,k);
		Q.put(k,k,diag-colSum);
	}
	// else skip and leave row k with zero values
	// Q.put(k, l, 0.0);		
}
return Q;   	
  }
 
开发者ID:mrc-ide,项目名称:PhyDyn,代码行数:27,代码来源:STreeLikelihoodExp.java

示例2: loadDataSet

import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
public static Pair<List<DoubleMatrix>, double[]> loadDataSet(BufferedReader stream, final int size, final int numAttributes) throws Exception
{
    // read LibSVM data
    double[] label_list = new double[size];
    List<DoubleMatrix> data_list = new ArrayList<>(size);

    for(int label_idx = 0; label_idx < size; ++label_idx)
    {
        String[] data = stream.readLine().trim().split("\\s+");
        label_list[label_idx] = Double.parseDouble(data[numAttributes]);

        DoubleMatrix feature_vector = DoubleMatrix.zeros(numAttributes);
        for (int idx = 0; idx < numAttributes; ++idx)
        {
            feature_vector.put(idx, Double.parseDouble(data[idx]));
            assert(feature_vector.get(idx) >= 0.0 && feature_vector.get(idx) <= 1.0);
        }
        data_list.add(feature_vector);
    }
    return new DMPair(data_list, label_list);
}
 
开发者ID:rdspring1,项目名称:LSH_DeepLearning,代码行数:22,代码来源:DLDataSet.java

示例3: loadDataSet

import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
public static Pair<List<DoubleMatrix>, double[]> loadDataSet(BufferedReader stream, final int size) throws IOException
{
    // read LibSVM data
    double[] label_list = new double[size];
    List<DoubleMatrix> data_list = new ArrayList<>(size);

    for(int label_idx = 0; label_idx < size; ++label_idx)
    {
        String[] data = stream.readLine().trim().split("\\s");
        label_list[label_idx] = Double.parseDouble(data[FEATURE_SIZE]);

        DoubleMatrix feature_vector = DoubleMatrix.zeros(FEATURE_SIZE);
        for (int idx = 0; idx < FEATURE_SIZE; ++idx)
        {
            feature_vector.put(idx, Double.parseDouble(data[idx]));
            assert(feature_vector.get(idx) >= -1.0 && feature_vector.get(idx) <= 1.0);
        }
        data_list.add(feature_vector);
    }
    assert(data_list.size() == size);
    return new DMPair(data_list, label_list);
}
 
开发者ID:rdspring1,项目名称:LSH_DeepLearning,代码行数:23,代码来源:NORBDataSet.java

示例4: computeQTrans

import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
protected DoubleMatrix computeQTrans(DoubleMatrix Y, DoubleMatrix F, DoubleMatrix G, DoubleMatrix Coef) {

    	DoubleMatrix Q = DoubleMatrix.zeros(numStates,numStates);
    	double rateOutByBirth, rateOutByMigration, totalRate;
    	for (int k = 0; k < numStates; k++) 
    	{
    		double rowSum = 0.0;
    		for (int l = 0; l < numStates; l++) 
    		{
    			if (k != l) 
    			{		// off-diagonal
    				if (Y.get(k) > 0) 
    				{
    					rateOutByBirth = F.get(l,k) * Coef.get(l) / Y.get(k);      // Birth in other deme (Backwards in time)
    					rateOutByMigration = G.get(l,k) / (Y.get(k)); 			// State change of lineages (Backwards in time)
    					totalRate = rateOutByBirth + rateOutByMigration;
    					Q.put(k, l, totalRate);
    					rowSum += totalRate;
    				} 
    				else
    				{																// diagonal
    					Q.put(k, l, 0.0);
    				}
    			}
    		}
    		Q.put(k,k,-rowSum);
    	}
    	return Q;
	
    }
 
开发者ID:mrc-ide,项目名称:PhyDyn,代码行数:31,代码来源:STreeLikelihoodExp.java

示例5: computeLambdaSum

import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
public double computeLambdaSum(int t, int childIdx1, int childIdx2) {
  	double lambda;
  	
  	DoubleMatrix F,Y;
  	Y = ts.getYs()[t];
  	F = ts.getFs()[t];	
  	
DoubleMatrix pa, pvec1, pvec2;		
pvec1 = stateProbabilities.getStateProbsFromIndex(childIdx1);
pvec2 = stateProbabilities.getStateProbsFromIndex(childIdx2);
/* previous version */
   DoubleMatrix coalRates = DoubleMatrix.zeros(numStates, numStates);
   for (int k = 0; k < numStates; k++) {
   	for (int l = 0; l < numStates; l++) {            	
   		final double Yk = Y.get(k);	
   		final double Yl = Y.get(l);	
   		//System.out.println("numStates="+numStates+"dim:"+F.rows+", "+F.columns);
   		lambda = F.get(k,l) / (Yk*Yl) 
   				* (pvec1.get(k) * pvec2.get(l)
   						+ pvec1.get(l) * pvec2.get(k));
   		coalRates.put(k, l, lambda);
   	}
   }
   lambda = coalRates.sum();
   pa = coalRates.rowSums().div(lambda).transpose(); // row-vector
   /* pa := new state probabilities of the lineage dt after coalescing */

  	return lambda;
  }
 
开发者ID:mrc-ide,项目名称:PhyDyn,代码行数:30,代码来源:STreeLikelihoodExp.java

示例6: getLineageStateSum

import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
@Override
public DoubleMatrix getLineageStateSum() {
	DoubleMatrix sumAk = DoubleMatrix.zeros(numStates);
  		for (int lin = 0; lin < numExtant; lin++) {
  			//System.out.println(extantProbs[lin]);
  			sumAk = sumAk.add(extantProbs[lin]);
  		}
   	return sumAk;  
}
 
开发者ID:mrc-ide,项目名称:PhyDyn,代码行数:10,代码来源:StateProbabilitiesArray.java

示例7: processSampleEvent

import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
protected void processSampleEvent(int interval) {
  	int sampleState;
List<Node> incomingLines = intervals.getLineagesAdded(interval);
for (Node l : incomingLines) {			
	/* uses pre-computed nodeNrToState */
	sampleState = nodeNrToState[l.getNr()];	/* suceeds if node is a leaf, otherwise state=-1 */	
	DoubleMatrix sVec = DoubleMatrix.zeros(1,numStates); // row-vector
	sVec.put(sampleState, 1.0);
	stateProbabilities.addLineage(l.getNr(),sVec);
}	
  }
 
开发者ID:mrc-ide,项目名称:PhyDyn,代码行数:12,代码来源:STreeLikelihood.java

示例8: vectorize

import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
public static DoubleMatrix vectorize(double[] data, int offset, int length)
{
    DoubleMatrix vector = DoubleMatrix.zeros(length);
    for(int idx = 0; idx < length; ++idx)
    {
        vector.put(idx, 0, data[offset + idx]);
    }
    return vector;
}
 
开发者ID:rdspring1,项目名称:LSH_DeepLearning,代码行数:10,代码来源:Util.java

示例9: compress

import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
public static DoubleMatrix compress(final int size, DoubleMatrix data)
{
    int compressSize = data.length / size;

    DoubleMatrix compressData = DoubleMatrix.zeros(compressSize);
    for(int idx = 0; idx < compressSize; ++idx)
    {
        int offset = idx * size;
        compressData.put(idx, sum(data, offset, offset + size));
    }
    return compressData;
}
 
开发者ID:rdspring1,项目名称:LSH_DeepLearning,代码行数:13,代码来源:Pooling.java

示例10: CorrMatrix

import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
public CorrMatrix(String[] colNames) {
    this.columnNames = colNames;
    this.colNum = new HashMap<String, Integer>(colNames.length);
    for (int i=0; i < colNames.length; i++)
        this.colNum.put(colNames[i], i);
    this.rawMatrix = new double[colNames.length][colNames.length];
    this.nonMissing = DoubleMatrix.zeros(colNames.length, colNames.length);
    this.means = new double[colNames.length];
    this.corrMatrix = null;
}
 
开发者ID:vmware,项目名称:hillview,代码行数:11,代码来源:CorrMatrix.java

示例11: initWeights

import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
private void initWeights() {
    weights = new DoubleMatrix[layers.length - 1];
    biasWeights = new DoubleMatrix[layers.length - 1];
    for (int i = 0; i < layers.length - 1; i++) {
        weights[i] = DoubleMatrix.randn(layers[i +1].rows, layers[i].rows).div(4);
        biasWeights[i] = DoubleMatrix.zeros(layers[i+1].rows);
    }
}
 
开发者ID:nordsam,项目名称:tic-tac-toe,代码行数:9,代码来源:NeuralNetwork.java

示例12: initMomentVectors

import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
private void initMomentVectors() {
    firstMomentVector = new DoubleMatrix[weights.length];
    secondMomentVector = new DoubleMatrix[weights.length];
    for (int i=0; i<firstMomentVector.length; i++) {
        firstMomentVector[i] = DoubleMatrix.zeros(1);
        secondMomentVector[i] = DoubleMatrix.zeros(1);
    }
}
 
开发者ID:nordsam,项目名称:tic-tac-toe,代码行数:9,代码来源:NeuralNetwork.java

示例13: testClone_cloneGetsSameValues

import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
@Test
public void testClone_cloneGetsSameValues() throws CloneNotSupportedException  {
    NeuralNetwork clone = (NeuralNetwork) network.clone();
    assertFalse(network == clone);
    assertTrue(network.getClass() == clone.getClass());
    assertTrue(clone.getWeights() == network.getWeights());
    DoubleMatrix[] x = new DoubleMatrix[2];
    x[0] = DoubleMatrix.ones(2);
    x[1] = DoubleMatrix.zeros(2);
    network.setWeights(x);
    assertFalse(clone.getWeights() == network.getWeights());
    clone.setWeights(x);
    assertTrue(clone.getWeights() == network.getWeights());
    assertTrue(clone.getLayers() == network.getLayers());
}
 
开发者ID:nordsam,项目名称:tic-tac-toe,代码行数:16,代码来源:NeuralNetworkTest.java

示例14: testAdd

import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
/**
 * Test of add method, of class ReplayMemory.
 */
@Test
public void testAdd() {
    System.out.println("add method test");
    DoubleMatrix state = DoubleMatrix.zeros(1);
    int action = 0;
    int reward = 0;
    DoubleMatrix nextState = DoubleMatrix.ones(1);
    ReplayMemory instance = new ReplayMemory(2);
    assertEquals(instance.getSize(), 0);
    instance.add(state, action, reward, nextState);
    assertEquals(instance.getSize(), 1);
    instance.add(state, action, reward, nextState);
    assertEquals(instance.getSize(), 2);
    instance.add(state, action, reward, nextState);
    assertEquals(instance.getSize(), 2);
    
    DoubleMatrix state2 = DoubleMatrix.ones(1);
    int action2 = 1;
    int reward2 = 1;
    DoubleMatrix nextState2 = DoubleMatrix.zeros(1);
    
    
    instance.add(state2, action2, reward2, nextState2);
    assertEquals(instance.getSize(), 2);
    instance.add(state2, action2, reward2, nextState2);
    assertEquals(instance.getSize(), 2);
    assertEquals(1, instance.getRandom().getAction());
}
 
开发者ID:nordsam,项目名称:tic-tac-toe,代码行数:32,代码来源:ReplayMemoryTest.java

示例15: testGetState

import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
/**
 * Test of getState method, of class Replay.
 */
@Test
public void testGetState() {
    System.out.println("getState");
    DoubleMatrix expResult = DoubleMatrix.zeros(1);
    DoubleMatrix result = instance.getState();
    assertEquals(expResult, result);
}
 
开发者ID:nordsam,项目名称:tic-tac-toe,代码行数:11,代码来源:ReplayTest.java


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