Jama.Matrix.minusEquals()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(94)

本文整理了Java中Jama.Matrix.minusEquals()方法的一些代码示例,展示了Matrix.minusEquals()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Matrix.minusEquals()方法的具体详情如下:
包路径:Jama.Matrix
类名称:Matrix
方法名:minusEquals

Matrix.minusEquals介绍

暂无

代码示例

代码示例来源: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: 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: 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

public Matrix sample_epoch(Matrix X_0) {
  int N = X_0.getArray().length;
  // POSITIVE
  Matrix Z_0 = sample_Z(X_0);                                             // sample up                              		
  Matrix E_pos = X_0.transpose().times(Z_0);                                // positive energy, H_1 * V_1
  // NEGATIVE
  Matrix X_1 = sample_X(Z_0);                                                // go down -- can either sample down 
  //Matrix X_1 = Mat.threshold(prob_X(Z_0),0.5);							// ... or just go down
  Matrix pZ_1 = prob_Z(X_1);                                               // go back up again
  Matrix E_neg = X_1.transpose().times(pZ_1);                                // negative energy, P(Z_1) * X_1
  // CALCULATE ERROR (Optional!)
  double _Err = MatrixUtils.meanSquaredError(X_0.getArray(), X_1.getArray());			// @note: this take some milliseconds to calculate
  System.out.println(""+_Err);
  // CONTRASTIVE DIVERGENCE
  Matrix CD = ((E_pos.minusEquals(E_neg)).times(1./N));					// CD = difference between energies
     return CD;
}

代码示例来源:origin: net.sf.meka/meka

public Matrix sample_epoch(Matrix X_0) {
  int N = X_0.getArray().length;
  // POSITIVE
  Matrix Z_0 = sample_Z(X_0);                                             // sample up                              		
  Matrix E_pos = X_0.transpose().times(Z_0);                                // positive energy, H_1 * V_1
  // NEGATIVE
  Matrix X_1 = sample_X(Z_0);                                                // go down -- can either sample down 
  //Matrix X_1 = Mat.threshold(prob_X(Z_0),0.5);							// ... or just go down
  Matrix pZ_1 = prob_Z(X_1);                                               // go back up again
  Matrix E_neg = X_1.transpose().times(pZ_1);                                // negative energy, P(Z_1) * X_1
  // CALCULATE ERROR (Optional!)
  double _Err = MatrixUtils.meanSquaredError(X_0.getArray(), X_1.getArray());			// @note: this take some milliseconds to calculate
  System.out.println(""+_Err);
  // CONTRASTIVE DIVERGENCE
  Matrix CD = ((E_pos.minusEquals(E_neg)).times(1./N));					// CD = difference between energies
     return CD;
}

代码示例来源:origin: net.sf.meka/meka

Matrix CD = ((E_pos.minusEquals(E_neg)).times(1./N));					// CD = difference between energies

代码示例来源:origin: Waikato/meka

Matrix CD = ((E_pos.minusEquals(E_neg)).times(1./N));					// CD = difference between energies

代码示例来源:origin: openimaj/openimaj

@Override
  protected void mstep(EMGMM gmm, GaussianMixtureModelEM learner, Matrix X, Matrix responsibilities,
      Matrix weightedXsum,
      double[] norm)
{
    // Eq. 12 from K. Murphy,
    // "Fitting a Conditional Linear Gaussian Distribution"
    final int nfeatures = X.getColumnDimension();
    for (int c = 0; c < learner.nComponents; c++) {
      final Matrix post = responsibilities.getMatrix(0, X.getRowDimension() - 1, c, c).transpose();
      final double factor = 1.0 / (ArrayUtils.sumValues(post.getArray()) + 10 * MathUtils.EPSILON);
      final Matrix pXt = X.transpose();
      for (int i = 0; i < pXt.getRowDimension(); i++)
        for (int j = 0; j < pXt.getColumnDimension(); j++)
          pXt.set(i, j, pXt.get(i, j) * post.get(0, j));
      final Matrix argcv = pXt.times(X).times(factor);
      final Matrix mu = ((FullMultivariateGaussian) gmm.gaussians[c]).mean;
      ((FullMultivariateGaussian) gmm.gaussians[c]).covar = argcv.minusEquals(mu.transpose().times(mu))
          .plusEquals(Matrix.identity(nfeatures, nfeatures).times(learner.minCovar));
    }
  }
},

代码示例来源:origin: gov.nist.math/jama

A.minusEquals(R);
Z = new Matrix(A.getRowDimension(),A.getColumnDimension());
try {
 A.minusEquals(S);
 errorCount = try_failure(errorCount,"minusEquals conformance check... ","nonconformance not raised");
} catch ( IllegalArgumentException e ) {

相关文章