L-BFGS performs more iterations than max_iterations parameter
No matter what value I set for the max_iterations value, it iterates a lot more. When setting it to 100, the avergage iterations made is 290. I found an old scipy issue that describes this as well, and it seems to be solved by setting a parameter that handles the 'number of function calls per iterations' to 1. Is it possible to do something similar here? Otherwise, how can I solve this? (I am using L-BFGS as an optimizer on a neural network for image recognition)
I know this is closed and two years old, but I also am experiencing this. Did you find a solution?
Can you share a minimal working example?
Can you share a minimal working example?
I still meet this issue, and below is a minimal example for it, set the max iteration = 30, but it will iterate around 90, 3 times of setting value
import numpy as np
import tensorflow_probability as tfp
# A high-dimensional quadratic bowl.
ndims = 60
minimum_ = np.ones([ndims], dtype='float64')
scales_ = np.arange(ndims, dtype='float64') + 1.0
i=0
# The objective function and the gradient.
def func_wrapper(scales, minimum):
def f(x):
f.iter = f.iter+1
print('Iter: ', f.iter)
return tfp.math.value_and_gradient(
lambda x: tf.reduce_sum(
scales * tf.math.squared_difference(x, minimum), axis=-1),
x)
f.iter = 0
return f
func = func_wrapper(scales_, minimum_)
start = np.arange(ndims, 0, -1, dtype='float64')
optim_results = tfp.optimizer.lbfgs_minimize(
func,
initial_position=start,
max_iterations=30
)
# Check that the search converged
print('Converged:?',optim_results.converged)
print(optim_results.position)