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


Java DoubleMatrix.putColumn方法代码示例

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


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

示例1: normalize

import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
public DoubleMatrix normalize(DoubleMatrix A) {
	
	DoubleMatrix B = new DoubleMatrix(A.rows, A.columns);
	DoubleMatrix max = A.columnMaxs();
	DoubleMatrix min = A.columnMins();
	
	logger.info("Normalizing hypercube into [0,1]^n...");

	for(int j=0; j<B.columns; j++) {
		double mx = max.get(j);
		double mn = min.get(j);
		if(mx == mn) {
			B.putColumn(j, DoubleMatrix.zeros(A.rows, 1));
			continue;
		}
		for(int i=0; i<B.rows; i++)
			B.put(i, j, (A.get(i, j) - mn) / (mx - mn));
	}
	
	save("C"+B.columns, B);
	
	return B;
}
 
开发者ID:AKSW,项目名称:Resource2Vec,代码行数:24,代码来源:JblasSVD.java

示例2: pca

import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
/**
 * 
 * 
 * @param A
 * @param dim
 * @return
 */
public DoubleMatrix pca(DoubleMatrix A, int dim) {
	
	logger.info("Type 'pca' started (target dimensions = "+dim+").");
	
	A = centerData(A);
	save("A", A);
	
	logger.info("Computing SVD...");
	DoubleMatrix[] usv = Singular.fullSVD(A);
	DoubleMatrix U = usv[0];
	DoubleMatrix S = usv[1];
	
	save("U", U);
	save("S", S);
	
	// 
	logger.info("Reducing U to Uk...");
	DoubleMatrix Uk = new DoubleMatrix(U.rows, dim);
	for(int i=0; i<dim; i++)
		Uk.putColumn(i, U.getColumn(i));
	save("Uk", Uk);
	
	// build S matrix
	logger.info("Reducing S to Sk...");
	DoubleMatrix Sk = new DoubleMatrix(dim, dim);
	for (int i = 0; i < dim; i++) {
		Sk.put(i, i, S.get(i));
	}
	save("Sk", Sk);
	
	// calculate principal component matrix...
	logger.info("Computing principal components...");
	DoubleMatrix B = Uk.mmul(Sk);
	save("B", B);
	
	return B;
	
}
 
开发者ID:AKSW,项目名称:Resource2Vec,代码行数:46,代码来源:JblasSVD.java

示例3: reconstruct2

import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
public DoubleMatrix reconstruct2(DoubleMatrix A, int k) {
		
		logger.info("Type 'reconstruct2' started...");

		A = centerData(A);
		save("A", A);
		
		DoubleMatrix[] usv = Singular.fullSVD(A);
		// n x n
		DoubleMatrix U = usv[0];
		// n x p
		DoubleMatrix S = usv[1];
		// p x p (straight)
		DoubleMatrix V = usv[2];
		
		save("U", U);
		save("S", S);
		save("V", V);
		
		for(int i = k; i < U.columns; i++)
			U.putColumn(i, DoubleMatrix.zeros(U.rows, 1));
		save("Uk", U);
		
		DoubleMatrix Sm = new DoubleMatrix(A.rows, A.columns);
		for (int i = 0; i < k; i++) {
			Sm.put(i, i, S.get(i));
		}
		save("Sk", Sm);
		
//		for (int i = k; i < V.rows; i++) {
//			V.putColumn(i, DoubleMatrix.zeros(1, V.columns));
//		}
//		visual("Vk", V);
 		
		// 
		DoubleMatrix Aapprox = U.mmul(Sm).mmul(V.transpose());
		save("Aapprox", Aapprox);
				
		return Aapprox;
	}
 
开发者ID:AKSW,项目名称:Resource2Vec,代码行数:41,代码来源:JblasSVD.java

示例4: getInputMatrix

import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
private DoubleMatrix getInputMatrix() {
    DoubleMatrix result = new DoubleMatrix(inputNeurons, BATCH_SIZE);
    for (int i=0; i < BATCH_SIZE; i++) {
        replay = replayMemory.getRandom();
        result.putColumn(i, replay.getState());
        if (replay.getReward() == 0) {
            expectedValue[i] = replay.getReward() + gamma * targetNetwork.forwardPropagate(replay.getNextState()).max();
        } else {
            expectedValue[i] = replay.getReward();
        }
        
        replays[i] = replay;
    }
    return result;
}
 
开发者ID:nordsam,项目名称:tic-tac-toe,代码行数:16,代码来源:NeuralQLearner.java

示例5: reconstruct

import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
/**
 * @param A
 * @param k
 * @return
 */
public DoubleMatrix reconstruct(DoubleMatrix A, int k) {
	
	logger.info("Type 'reconstruct' started...");

	A = centerData(A);
	save("A", A);
	
	DoubleMatrix[] usv = Singular.fullSVD(A);
	// n x n
	DoubleMatrix U = usv[0];
	// n x p
	DoubleMatrix S = usv[1];
	// p x p (straight)
	DoubleMatrix V = usv[2];
	
	save("U", U);
	save("S", S);
	save("V", V);
	
	// n x k
	DoubleMatrix Uk = new DoubleMatrix(U.rows, k);
	for(int i=0; i<k; i++)
		Uk.putColumn(i, U.getColumn(i));
	save("Uk", Uk);
	
	// k x k
	DoubleMatrix Sk = new DoubleMatrix(k, k);
	for (int i = 0; i < k; i++) {
		Sk.put(i, i, S.get(i));
	}
	save("Sk", Sk);
	
	// p x k (straight)
	DoubleMatrix Vk = new DoubleMatrix(A.columns, k);
	for (int i = 0; i < k; i++) {
		Vk.putColumn(i, V.getColumn(i));
	}
	save("Vk", Vk);
		
	// 
	DoubleMatrix Aapprox = Uk.mmul(Sk).mmul(Vk.transpose());
	save("Aapprox", Aapprox);
	
	DoubleMatrix Areduced = new DoubleMatrix(A.rows, k);
	for(int i=0; i<k; i++)
		Areduced.putColumn(i, Aapprox.getColumn(i));
	save("C"+k, Areduced);
	
	return Areduced;
	
}
 
开发者ID:AKSW,项目名称:Resource2Vec,代码行数:57,代码来源:JblasSVD.java


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