* 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