class_docstr: Tests for BFGS optimization algorithm.
class_docstr_tok: ["Tests","for","BFGS","optimization","algorithm","."]
docstr: Tests that the results are determinsitic.
docstr_tok: ["Tests","that","the","results","are","determinsitic","."]
code: def test_determinism(self):
      """Tests that the results are determinsitic."""
      dim = 5
  
      @_make_val_and_grad_fn
      def rastrigin(x):
          """The value and gradient of the Rastrigin function.
  
          The Rastrigin function is a standard optimization test case. It is a
          multimodal non-convex function. While it has a large number of local
          minima, the global minimum is located at the origin and where the function
          value is zero. The standard search domain for optimization problems is the
          hypercube [-5.12, 5.12]**d in d-dimensions.
  
          Args:
            x: Real `Tensor` of shape [2]. The position at which to evaluate the
              function.
  
          Returns:
            value_and_gradient: A tuple of two `Tensor`s containing
              value: A scalar `Tensor` of the function value at the supplied point.
              gradient: A `Tensor` of shape [2] containing the gradient of the
                function along the two axes.
          """
          return (
              tf.reduce_sum(x**2 - 10.0 * tf.cos(2 * np.pi * x))
              + 10.0 * dim
          )
  
      start_position = np.random.rand(dim) * 2.0 * 5.12 - 5.12
  
      def get_results():
          start = tf.constant(start_position)
          return self.evaluate(
              bfgs.minimize(
                  rastrigin, initial_position=start, tolerance=1e-5
              )
          )
  
      res1, res2 = get_results(), get_results()
  
      self.assertTrue(res1.converged)
      self.assertEqual(res1.converged, res2.converged)
      self.assertEqual(res1.failed, res2.failed)
      self.assertEqual(
          res1.num_objective_evaluations, res2.num_objective_evaluations
      )
      self.assertArrayNear(res1.position, res2.position, 1e-5)
      self.assertAlmostEqual(res1.objective_value, res2.objective_value)
      self.assertArrayNear(
          res1.objective_gradient, res2.objective_gradient, 1e-5
      )
      self.assertArrayNear(
          res1.inverse_hessian_estimate.reshape([-1]),
          res2.inverse_hessian_estimate.reshape([-1]),
          1e-5,
      )
  
imports: from absl.testing import parameterized
  import numpy
  from scipy.stats import special_ortho_group
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.math import gradient
  from tensorflow_probability.python.optimizer import bfgs
  from tensorflow_probability.python.optimizer import bfgs_utils
label_desc: Use image node_id 17 for calling the BfgsTest obj's underlying member method code with example usage: obj.test_determinism() and returns: unknown, self