Package org.encog.mathutil.matrices.decomposition

Examples of org.encog.mathutil.matrices.decomposition.LUDecomposition


   *            right hand side.
   * @return Solution if A is square, least squares solution otherwise.
   */
  public final Matrix solve(final Matrix b) {
    if (getRows() == getCols()) {
      return (new LUDecomposition(this)).solve(b);
    } else {
      return (new QRDecomposition(this)).solve(b);
    }
  }
View Full Code Here


   * Perform one iteration.
   */
  @Override
  public void iteration() {

    LUDecomposition decomposition = null;
    preIteration();

    this.weights = NetworkCODEC.networkToArray(this.network);

    double sumOfSquaredErrors = jacobianByFiniteDifference();

    // this.setError(j.getError());
    calculateHessian();

    // Define the objective function
    // bayesian regularization objective function
    final double objective = this.beta * sumOfSquaredErrors;
    double current = objective + 1.0;

    // Start the main Levenberg-Macquardt method
    this.lambda /= LevenbergMarquardtTraining.SCALE_LAMBDA;

    // We'll try to find a direction with less error
    // (or where the objective function is smaller)
    while ((current >= objective)
        && (this.lambda < LevenbergMarquardtTraining.LAMBDA_MAX)) {
      this.lambda *= LevenbergMarquardtTraining.SCALE_LAMBDA;

      // Update diagonal (Levenberg-Marquardt formula)
      for (int i = 0; i < this.parametersLength; i++) {
        this.hessian[i][i] = this.diagonal[i] + this.lambda;
      }

      // Decompose to solve the linear system
      decomposition = new LUDecomposition(this.hessianMatrix);

      // Check if the Jacobian has become non-invertible
      if (!decomposition.isNonsingular()) {
        continue;
      }

      // Solve using LU (or SVD) decomposition
      this.deltas = decomposition.Solve(this.gradient);

      // Update weights using the calculated deltas
      updateWeights();

      // Calculate the new error
View Full Code Here

   *            right hand side.
   * @return Solution if A is square, least squares solution otherwise.
   */
  public Matrix solve(final Matrix b) {
    if (getRows() == getCols()) {
      return (new LUDecomposition(this)).solve(b);
    } else {
      return (new QRDecomposition(this)).solve(b);
    }
  }
View Full Code Here

   */
  private MatrixMath() {
  }
 
  public static double determinant(Matrix m) {
    return new LUDecomposition(m).det();
  }
View Full Code Here

    if( !initComplete ) {
      this.hessian.init(network, getTraining());
      this.initComplete = true;
    }

    LUDecomposition decomposition = null;
    preIteration();

    this.hessian.clear();
    this.weights = NetworkCODEC.networkToArray(this.network);
   
    this.hessian.compute();     
    double currentError = this.hessian.getSSE();
    saveDiagonal();

    final double startingError = currentError;
    boolean done = false;
    boolean singular;

    while (!done) {
      applyLambda();
      decomposition = new LUDecomposition(this.hessian.getHessianMatrix());
     
      singular = decomposition.isNonsingular();

      if (singular) {
        this.deltas = decomposition.Solve(this.hessian.getGradients());
        updateWeights();
        currentError = calculateError();       
      }
     
      if ( !singular ||  currentError >= startingError) {
View Full Code Here

TOP

Related Classes of org.encog.mathutil.matrices.decomposition.LUDecomposition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.