本文整理了Java中Jama.Matrix.timesEquals()
方法的一些代码示例,展示了Matrix.timesEquals()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Matrix.timesEquals()
方法的具体详情如下:
包路径:Jama.Matrix
类名称:Matrix
方法名:timesEquals
暂无
代码示例来源:origin: openimaj/openimaj
/**
* Multiply all elements by a constant.
*
* @param d
* the multiplication factor.
*/
public void applyMultiplication(double d) {
matrix.timesEquals(d);
}
代码示例来源:origin: openimaj/openimaj
/**
* Zero the matrix
*
* @param m
* the matrix
*/
public static void zero(Matrix m) {
m.timesEquals(0);
}
代码示例来源:origin: openimaj/openimaj
/**
* @param m new data to update the SVD with
* @param dampening each current eigen vector is weighted by this amount
*/
public void update(Matrix m, double dampening){
Matrix d = Matrix.identity(this.updateK, this.updateK);
update(m,d.timesEquals(dampening));
}
/**
代码示例来源:origin: openimaj/openimaj
@Override
public Matrix getCovariance() {
final int d = mean.getColumnDimension();
return Matrix.identity(d, d).timesEquals(variance);
}
代码示例来源:origin: org.openimaj/sandbox
/**
* @param m new data to update the SVD with
* @param dampening each current eigen vector is weighted by this amount
*/
public void update(Matrix m, double dampening){
Matrix d = Matrix.identity(this.updateK, this.updateK);
update(m,d.timesEquals(dampening));
}
/**
代码示例来源:origin: broadgsa/gatk-protected
public void precomputeDenominatorForVariationalBayes( final double sumHyperParameterLambda ) {
// Variational Bayes calculations from Bishop
precomputeInverse();
cachedSigmaInverse.timesEquals( hyperParameter_a );
double sum = 0.0;
for(int jjj = 1; jjj <= mu.length; jjj++) {
sum += Gamma.digamma( (hyperParameter_a + 1.0 - jjj) / 2.0 );
}
sum -= Math.log( sigma.det() );
sum += Math.log(2.0) * mu.length;
final double lambda = 0.5 * sum;
final double pi = Gamma.digamma( hyperParameter_lambda ) - Gamma.digamma( sumHyperParameterLambda );
final double beta = (-1.0 * mu.length) / (2.0 * hyperParameter_b);
cachedDenomLog10 = (pi / Math.log(10.0)) + (lambda / Math.log(10.0)) + (beta / Math.log(10.0));
}
代码示例来源:origin: net.sf.meka/meka
/**
* Update - Carry out one epoch of CD, update W.
* We use dW_ to manage momentum.
* <br>
* TODO weight decay SHOULD NOT BE APPLIED TO BIASES
* @param X X
*/
public void update(Matrix X) {
Matrix CD = epoch(X);
Matrix dW = (CD.minusEquals(this.W.times(COST))).timesEquals(LEARNING_RATE); // with COST
this.W.plusEquals(dW.plus(this.dW_.timesEquals(MOMENTUM))); // with MOMENTUM.
this.dW_ = dW; // for the next update
}
代码示例来源:origin: Waikato/meka
/**
* Update - Carry out one epoch of CD, update W.
* We use dW_ to manage momentum.
* <br>
* TODO weight decay SHOULD NOT BE APPLIED TO BIASES
* @param X X
*/
public void update(Matrix X) {
Matrix CD = epoch(X);
Matrix dW = (CD.minusEquals(this.W.times(COST))).timesEquals(LEARNING_RATE); // with COST
this.W.plusEquals(dW.plus(this.dW_.timesEquals(MOMENTUM))); // with MOMENTUM.
this.dW_ = dW; // for the next update
}
代码示例来源:origin: net.sf.meka/meka
/**
* InitWeights - Initialize a BPNN of H.length hidden layers with H[0], H[1], etc hidden units in each layer (W will be random, and of the corresponding dimensions).
* @param d number of visible units
* @param L number of labels (output units)
* @param H number of units in hidden layers, H.length = number of hidden layers. CURRENTLY LIMITED TO 1.
*/
public void initWeights(int d, int L, int H[]) throws Exception {
int numHidden = H.length;
if (getDebug()) {
System.out.println("Initializing "+(H.length)+" hidden Layers ...");
System.out.println("d = "+d);
System.out.println("L = "+L);
}
// We need weights for Z to Y, as well as from X to Z
Matrix W[] = new Matrix[H.length+1];
int h = H[0];
H = new int[]{d,h,L};
// Hidden layers
System.out.println(""+Arrays.toString(H));
for(int n = 0; n < H.length-1; n++) {
W[n] = MatrixUtils.randomn(H[n] + 1, H[n + 1], r).timesEquals(0.1);
if (getDebug()) System.out.println("W["+n+"] = "+(H[n]+1)+" x "+H[n+1]);
}
//setWeights(W, L);
this.W = W;
makeMomentumMatrices();
}
代码示例来源:origin: Waikato/meka
/**
* Preset Weights - Initialize a BPNN with (pre-trained) weight matrices W (which also determines X dimensions).
* @param W pre-trained weight matrix (should include bias weights, assume W[-1]-1 hidden units in penultimate layer not including bias])
* @param L the number of labels (for making the final matrix)
*/
public void presetWeights(Matrix W[], int L) throws Exception {
r = new Random(0);
this.W = new Matrix[W.length+1];
for(int l = 0; l < W.length; l++) {
this.W[l] = W[l];
}
int h = W[1].getRowDimension()-1;
this.W[W.length] = MatrixUtils.randomn(h + 1, L, r).timesEquals(0.1);
makeMomentumMatrices();
}
代码示例来源:origin: net.sf.meka/meka
/**
* Preset Weights - Initialize a BPNN with (pre-trained) weight matrices W (which also determines X dimensions).
* @param W pre-trained weight matrix (should include bias weights, assume W[-1]-1 hidden units in penultimate layer not including bias])
* @param L the number of labels (for making the final matrix)
*/
public void presetWeights(Matrix W[], int L) throws Exception {
r = new Random(0);
this.W = new Matrix[W.length+1];
for(int l = 0; l < W.length; l++) {
this.W[l] = W[l];
}
int h = W[1].getRowDimension()-1;
this.W[W.length] = MatrixUtils.randomn(h + 1, L, r).timesEquals(0.1);
makeMomentumMatrices();
}
代码示例来源:origin: Waikato/meka
/**
* InitWeights - Initialize a BPNN of H.length hidden layers with H[0], H[1], etc hidden units in each layer (W will be random, and of the corresponding dimensions).
* @param d number of visible units
* @param L number of labels (output units)
* @param H number of units in hidden layers, H.length = number of hidden layers. CURRENTLY LIMITED TO 1.
*/
public void initWeights(int d, int L, int H[]) throws Exception {
int numHidden = H.length;
if (getDebug()) {
System.out.println("Initializing "+(H.length)+" hidden Layers ...");
System.out.println("d = "+d);
System.out.println("L = "+L);
}
// We need weights for Z to Y, as well as from X to Z
Matrix W[] = new Matrix[H.length+1];
int h = H[0];
H = new int[]{d,h,L};
// Hidden layers
System.out.println(""+Arrays.toString(H));
for(int n = 0; n < H.length-1; n++) {
W[n] = MatrixUtils.randomn(H[n] + 1, H[n + 1], r).timesEquals(0.1);
if (getDebug()) System.out.println("W["+n+"] = "+(H[n]+1)+" x "+H[n+1]);
}
//setWeights(W, L);
this.W = W;
makeMomentumMatrices();
}
代码示例来源:origin: net.sf.meka/meka
/**
* Update - Carry out one epoch of CD, update W.
* <br>
* TODO combine with above fn.
* @param X X
* @param s multiply the gradient by this scalar
*/
public void update(Matrix X, double s) {
Matrix CD = epoch(X);
Matrix dW = (CD.minusEquals(this.W.times(COST))).timesEquals(LEARNING_RATE); // with COST
dW = dW.times(s); // *scaling factor
this.W.plusEquals(dW.plus(this.dW_.timesEquals(MOMENTUM))); // with MOMENTUM.
this.dW_ = dW; // for the next update
}
代码示例来源:origin: Waikato/meka
/**
* Update - Carry out one epoch of CD, update W.
* <br>
* TODO combine with above fn.
* @param X X
* @param s multiply the gradient by this scalar
*/
public void update(Matrix X, double s) {
Matrix CD = epoch(X);
Matrix dW = (CD.minusEquals(this.W.times(COST))).timesEquals(LEARNING_RATE); // with COST
dW = dW.times(s); // *scaling factor
this.W.plusEquals(dW.plus(this.dW_.timesEquals(MOMENTUM))); // with MOMENTUM.
this.dW_ = dW; // for the next update
}
代码示例来源:origin: senbox-org/s1tbx
CrMat.timesEquals(1.0 / num);
CiMat.timesEquals(1.0 / num);
for (int i = 0; i < 4; i++) {
Cr[i][0] = CrMat.get(i, 0);
代码示例来源:origin: senbox-org/s1tbx
CrMat.timesEquals(1.0 / num);
CiMat.timesEquals(1.0 / num);
代码示例来源:origin: broadgsa/gatk-protected
public void evaluateFinalModelParameters( final List<VariantDatum> data ) {
sumProb = 0.0;
zeroOutMu();
zeroOutSigma();
int datumIndex = 0;
for( final VariantDatum datum : data ) {
final double prob = pVarInGaussian.get(datumIndex++);
sumProb += prob;
incrementMu( datum, prob );
}
divideEqualsMu( sumProb );
datumIndex = 0;
final Matrix pVarSigma = new Matrix(mu.length, mu.length);
for( final VariantDatum datum : data ) {
final double prob = pVarInGaussian.get(datumIndex++);
for( int iii = 0; iii < mu.length; iii++ ) {
for( int jjj = 0; jjj < mu.length; jjj++ ) {
pVarSigma.set(iii, jjj, prob * (datum.annotations[iii]-mu[iii]) * (datum.annotations[jjj]-mu[jjj]));
}
}
sigma.plusEquals( pVarSigma );
}
sigma.timesEquals( 1.0 / sumProb );
resetPVarInGaussian(); // clean up some memory
}
代码示例来源:origin: senbox-org/s1tbx
CrMat.timesEquals(1.0 / num);
CiMat.timesEquals(1.0 / num);
代码示例来源:origin: openimaj/openimaj
final Matrix m = cv.plus(Matrix.identity(ndims, ndims).timesEquals(MIN_COVAR_RECONDITION));
cv_chol = m.chol().getL();
代码示例来源:origin: senbox-org/s1tbx
TrMat.timesEquals(1.0 / num);
TiMat.timesEquals(1.0 / num);
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
内容来源于网络,如有侵权,请联系作者删除!