From 3e9c266d0d9f591c56350a1eacf02c489fd81f62 Mon Sep 17 00:00:00 2001 From: Max Zwiessele Date: Wed, 22 May 2013 12:35:46 +0100 Subject: [PATCH] structural changes for printing --- GPy/inference/SCG.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/GPy/inference/SCG.py b/GPy/inference/SCG.py index 83ea054f..d0a30f0d 100644 --- a/GPy/inference/SCG.py +++ b/GPy/inference/SCG.py @@ -39,11 +39,6 @@ def SCG(f, gradf, x, optargs=(), maxiters=500, max_f_eval=500, display=True, xto function_eval number of fn evaluations status: string describing convergence status """ - - if display: - print " SCG" - print ' {0:{mi}s} {1:11s} {2:11s} {3:11s}'.format("I", "F", "Scale", "|g|", mi=len(str(maxiters))) - if xtol is None: xtol = 1e-6 if ftol is None: @@ -69,6 +64,9 @@ def SCG(f, gradf, x, optargs=(), maxiters=500, max_f_eval=500, display=True, xto iteration = 0 + if display: + print ' {0:{mi}s} {1:11s} {2:11s} {3:11s}'.format("I", "F", "Scale", "|g|", mi=len(str(maxiters))) + # Main optimization loop. while iteration < maxiters: @@ -129,10 +127,10 @@ def SCG(f, gradf, x, optargs=(), maxiters=500, max_f_eval=500, display=True, xto else: # Update variables for new position - fold = fnew - gradold = gradnew gradnew = gradf(x, *optargs) current_grad = np.dot(gradnew, gradnew) + gradold = gradnew + fold = fnew # If the gradient is zero then we are done. if current_grad <= gtol: status = 'converged'