本文整理汇总了Java中no.uib.cipr.matrix.DenseVector.getData方法的典型用法代码示例。如果您正苦于以下问题:Java DenseVector.getData方法的具体用法?Java DenseVector.getData怎么用?Java DenseVector.getData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类no.uib.cipr.matrix.DenseVector
的用法示例。
在下文中一共展示了DenseVector.getData方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: derivative
import no.uib.cipr.matrix.DenseVector; //导入方法依赖的package包/类
@Override
public VectorParameters derivative(Model model, double[] data) {
final double[][] as = model.getLayerActivations(data);
final double[] d2 = new double[as[1].length];
for (int i = 0; i < d2.length; i++) {
d2[i] = -(data[i] - as[1][i]) * (as[1][i] * (1 - as[1][i]));
}
final DenseVector wd = (DenseVector) model.w1.transMult(new DenseVector(d2),
new DenseVector(model.w1.numColumns()));
final double[] d1 = wd.getData();
for (int i = 0; i < d1.length; i++) {
d1[i] *= (as[0][i] * (1 - as[0][i]));
}
return null;
}
示例2: symmetricGeneralisedEigenvectors
import no.uib.cipr.matrix.DenseVector; //导入方法依赖的package包/类
/**
* Solve the general problem A x = L B x.
* The returned eigenvalues are not ordered.
*
* @param A symmetric matrix A
* @param B symmetric matrix B
* @return The eigenvectors x and eigenvalues L.
*/
public static IndependentPair<Matrix, double[]> symmetricGeneralisedEigenvectors(Matrix A, Matrix B) {
if ((A.getRowDimension() != A.getColumnDimension()) || (B.getRowDimension() != B.getColumnDimension()))
throw new IllegalArgumentException("Input matrices must be square");
int dim = A.getRowDimension();
DenseMatrix vecs = new DenseMatrix(A.getArray());
DenseVector W = new DenseVector(dim);
sygvd(1, "V", "U", vecs, new DenseMatrix(B.getArray()), W);
Matrix evecs = new Matrix(dim, dim);
final double[][] evecsData = evecs.getArray();
final double[] vecsData = vecs.getData();
for (int r=0; r<dim; r++)
for (int c=0; c<dim; c++)
evecsData[r][c] = vecsData[r + c * dim];
return new IndependentPair<Matrix, double[]>(evecs, W.getData());
}
示例3: symmetricGeneralisedEigenvectorsSorted
import no.uib.cipr.matrix.DenseVector; //导入方法依赖的package包/类
/**
* Solve the general problem A x = L B x.
* The returned eigenvalues ordered in a decreasing manner.
*
* @param A symmetric matrix A
* @param B symmetric matrix B
* @return The eigenvectors x and eigenvalues L.
*/
public static IndependentPair<Matrix, double[]> symmetricGeneralisedEigenvectorsSorted(Matrix A, Matrix B) {
if ((A.getRowDimension() != A.getColumnDimension()) || (B.getRowDimension() != B.getColumnDimension()))
throw new IllegalArgumentException("Input matrices must be square");
int dim = A.getRowDimension();
DenseMatrix vecs = new DenseMatrix(A.getArray());
DenseVector W = new DenseVector(dim);
sygvd(1, "V", "U", vecs, new DenseMatrix(B.getArray()), W);
Matrix evecs = new Matrix(dim, dim);
final double[][] evecsData = evecs.getArray();
final double[] vecsData = vecs.getData();
final double[] valsData = W.getData();
int [] indices = ArrayUtils.range(0, valsData.length-1);
ArrayUtils.parallelQuicksortDescending(valsData, indices);
for (int r=0; r<dim; r++)
for (int c=0; c<dim; c++)
evecsData[r][c] = vecsData[r + indices[c] * dim];
return new IndependentPair<Matrix, double[]>(evecs, valsData);
}
示例4: feedforward
import no.uib.cipr.matrix.DenseVector; //导入方法依赖的package包/类
double[] feedforward(double[] input) {
final DenseVector iv = new DenseVector(input, false);
final DenseVector a1 = sigmoid(w1.multAdd(iv, b1.copy()));
final DenseVector a2 = sigmoid(w2.multAdd(a1, b2.copy()));
return a2.getData();
}
示例5: symmetricGeneralisedEigenvalues
import no.uib.cipr.matrix.DenseVector; //导入方法依赖的package包/类
/**
* Compute the generalised eigenvalues, L, of the problem A x = L B x.
* The returned eigenvalues are not ordered.
*
* @param A symmetric Matrix A; only the upper triangle is used.
* @param B symmetric Matrix B; only the upper triangle is used.
* @return the eigenvalues L.
*/
public static double[] symmetricGeneralisedEigenvalues(Matrix A, Matrix B) {
if ((A.getRowDimension() != A.getColumnDimension()) || (B.getRowDimension() != B.getColumnDimension()))
throw new IllegalArgumentException("Input matrices must be square");
DenseVector W = new DenseVector(A.getRowDimension());
sygvd(1, "N", "U", new DenseMatrix(A.getArray()), new DenseMatrix(B.getArray()), W);
return W.getData();
}
示例6: 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];
}
示例7: getLayerActivations
import no.uib.cipr.matrix.DenseVector; //导入方法依赖的package包/类
double[][] getLayerActivations(double[] input) {
final DenseVector iv = new DenseVector(input, false);
final DenseVector a1 = sigmoid(w1.multAdd(iv, b1.copy()));
final DenseVector a2 = sigmoid(w2.multAdd(a1, b2.copy()));
return new double[][] { a1.getData(), a2.getData() };
}
示例8: sigmoid
import no.uib.cipr.matrix.DenseVector; //导入方法依赖的package包/类
private DenseVector sigmoid(Vector vector) {
final DenseVector out = (DenseVector) vector.copy();
final double[] xd = out.getData();
for (int i = 0; i < xd.length; i++)
xd[i] = 1 / (1 + Math.exp(-xd[i]));
return out;
}