diff --git a/tensorflow_quantum/python/optimizers/spsa_minimizer.py b/tensorflow_quantum/python/optimizers/spsa_minimizer.py index 471b46d9e..0b2cc11bd 100644 --- a/tensorflow_quantum/python/optimizers/spsa_minimizer.py +++ b/tensorflow_quantum/python/optimizers/spsa_minimizer.py @@ -135,7 +135,7 @@ def minimize(expectation_value_function, tolerance=1e-5, max_iterations=200, alpha=0.602, - learning_rate=1.0, + learning_rate=0.31, perturb=1.0, gamma=0.101, blocking=False, @@ -277,7 +277,7 @@ def _body(state): """Main optimization loop.""" new_learning_rate = learning_rate_init / ( (tf.cast(state.num_iterations + 1, tf.float32) + - 0.01 * tf.cast(max_iterations, tf.float32))**state.alpha) + 0.1 * tf.cast(max_iterations, tf.float32))**state.alpha) new_perturb = perturb_init / (tf.cast(state.num_iterations + 1, tf.float32)**state.gamma) diff --git a/tensorflow_quantum/python/optimizers/spsa_minimizer_test.py b/tensorflow_quantum/python/optimizers/spsa_minimizer_test.py index 1de86d86c..270c47de2 100644 --- a/tensorflow_quantum/python/optimizers/spsa_minimizer_test.py +++ b/tensorflow_quantum/python/optimizers/spsa_minimizer_test.py @@ -106,7 +106,7 @@ def test_quadratic_function_optimization(self): func = lambda x: tf.math.reduce_sum(np.power(x, 2) * coefficient) result = spsa_minimizer.minimize(func, tf.random.uniform(shape=[n])) - self.assertAlmostEqual(func(result.position).numpy(), 0, delta=2e-4) + self.assertAlmostEqual(func(result.position).numpy(), 0, delta=1e-4) self.assertTrue(result.converged) def test_noisy_sin_function_optimization(self):