本文整理汇总了Java中org.jblas.DoubleMatrix.putRow方法的典型用法代码示例。如果您正苦于以下问题:Java DoubleMatrix.putRow方法的具体用法?Java DoubleMatrix.putRow怎么用?Java DoubleMatrix.putRow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jblas.DoubleMatrix
的用法示例。
在下文中一共展示了DoubleMatrix.putRow方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNdGaussianBlobs
import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
/**
* Return a numerical table with numBlobs clusters, every cluster containing numPointsPerBlob n-dimensional
* points sampled from a Gaussian centered at a random point in the nD unit hyperbox, with a standard deviation
* of stdDev.
*/
public static ITable getNdGaussianBlobs(int numBlobs, int numPointsPerBlob, int n, double stdDev) {
DoubleMatrix data = new DoubleMatrix(numBlobs * numPointsPerBlob, n);
Random rnd = new Random(42);
for (int i = 0; i < numBlobs; i++) {
DoubleMatrix center = new DoubleMatrix(1, n);
for (int j = 0; j < n; j++) {
center.put(j, 20 * rnd.nextDouble());
}
for (int j = 0; j < numPointsPerBlob; j++) {
DoubleMatrix delta = new DoubleMatrix(1, n);
for (int k = 0; k < n; k++) {
delta.put(k, rnd.nextGaussian() * stdDev);
}
data.putRow(i * numPointsPerBlob + j, center.add(delta));
}
}
return BlasConversions.toTable(data);
}
示例2: loadMatrix
import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
private static DoubleMatrix loadMatrix(String dir, int dim) throws FileNotFoundException {
String input = "etc/"+dir+"/D"+dim+".csv";
Scanner in = new Scanner(new File(input));
int length = 0;
while(in.hasNextLine()) {
in.nextLine();
length++;
}
System.out.println(length + " x "+dim);
DoubleMatrix t = new DoubleMatrix(length, dim);
in.close();
in = new Scanner(new File(input));
for(int i=0; in.hasNextLine(); i++) {
String[] coord = in.nextLine().split("\t");
DoubleMatrix v = new DoubleMatrix(1, coord.length);
for(int j=0; j<coord.length; j++)
v.put(j, Double.parseDouble(coord[j]));
t.putRow(i, v);
}
in.close();
return t;
}
示例3: learnWhiteningMatrix
import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
public void learnWhiteningMatrix(ArrayList<T> data) {
this.means = getMeans(data);
DoubleMatrix X = new DoubleMatrix(data.size(), this.dimension);
// Center observations w.r.t. their means
int row = 0;
for(T t : data) {
DoubleMatrix x_i = this.getOutput(t);
X.putRow(row++, x_i.subi(means, x_i).transpose());
}
// Sphericize data
DoubleMatrix M = X.transpose().mmul(X);
M.divi(data.size(), M);
DoubleMatrix[] ED = Eigen.symmetricEigenvectors(M);
DoubleMatrix E = ED[0];
DoubleMatrix D = ED[1];
//DoubleMatrix D_invrt = Solve.pinv(sqrt(D));
DoubleMatrix D_invrt = diagPow(D, -0.5);
this.whitener = E.mmul(D_invrt);
this.wasWhitened = true;
checkSampleCovariance(X.mmul(this.whitener));
//DoubleMatrix X_std = X.mmul(E).mmul(D_invrt);
}
示例4: getStringEmbeddingsByPCA
import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
public static StringEmbeddings getStringEmbeddingsByPCA(StringEmbeddings embeddings, int dimension) {
ArrayList<String> keys = new ArrayList<String>();
HashMap<String, DoubleMatrix> original = embeddings.getAllVectors();
keys.addAll(original.keySet());
if(keys.size() == 0 || original.get(keys.get(0)).length == dimension) {
return embeddings;
}
int originalDimension = original.get(keys.get(0)).length;
DoubleMatrix mat = new DoubleMatrix(keys.size(), originalDimension);
for(int r=0; r<keys.size(); r++){
mat.putRow(r, original.get(keys.get(r)).transpose());
}
DoubleMatrix reduced = reduceByPCA(mat, dimension);
StringEmbeddings newEmbeddings = new StringEmbeddings();
for(int r=0; r<keys.size(); r++){
newEmbeddings.addEmbedding(keys.get(r), reduced.getRow(r).transpose());
}
return newEmbeddings;
}
示例5: createVectorMatrix
import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
public DoubleMatrix createVectorMatrix(String[] words, WordVectors v) {
DoubleMatrix m = new DoubleMatrix(words.length, columns);
for (int i = 0; i < words.length; i ++) {
m.putRow(i, new DoubleMatrix(v.getWordVector(words[i])));
}
return m;
}