class_docstr: To run: "python -m saliency.tf1.utils_test" from the top-level directory.
class_docstr_tok: ["To","run",":","``","python","-m","saliency.tf1.utils_test","''","from","the","top-level","directory","."]
docstr: Tests that three expected keys are returned correctly.
docstr_tok: ["Tests","that","three","expected","keys","are","returned","correctly","."]
code: def testThreeKeysSuccess(self):
      """Tests that three expected keys are returned correctly."""
      with self.graph.as_default():
          x = tf.placeholder(shape=[None, 3], dtype=np.float32)
          conv_layer = -2 * x[:, 0] + 5 * x[:, 1] * x[:, 1]
          y = (conv_layer[:] * 2)[0]
      x_value = np.array([[2, 0.5, 19]], dtype=np.float32)
      # because x[1] is squared, gradient should be 5*2x = 5*2*0.2
      expected_conv_layer = [-2 * 2 + 5 * 0.5 * 0.5]
      # because x[1] is squared, gradient should be 5*2x = 5*2*0.5
      expected_conv_gradient = np.array([2], dtype=np.float32)
      expected_output_gradient = np.array([[-2.0, 5.0, 0.0]]) * 2
  
      call_model_function = utils.create_tf1_call_model_function(
          self.graph, self.sess, y=y, x=x, conv_layer=conv_layer
      )
      data = call_model_function(
          x_value,
          call_model_args=None,
          expected_keys=[
              utils.CONVOLUTION_LAYER_VALUES,
              utils.INPUT_OUTPUT_GRADIENTS,
              utils.CONVOLUTION_OUTPUT_GRADIENTS,
          ],
      )
      actual_conv_gradient = data[utils.CONVOLUTION_OUTPUT_GRADIENTS]
      actual_output_gradient = data[utils.INPUT_OUTPUT_GRADIENTS]
      actual_conv_layer = data[utils.CONVOLUTION_LAYER_VALUES]
  
      self.assertIsNone(
          np.testing.assert_almost_equal(
              expected_conv_gradient, actual_conv_gradient
          )
      )
      self.assertIsNone(
          np.testing.assert_almost_equal(
              expected_conv_layer, actual_conv_layer
          )
      )
      self.assertIsNone(
          np.testing.assert_almost_equal(
              expected_output_gradient, actual_output_gradient
          )
      )
  
file_path: saliency/saliency/tf1/utils_test.py
imports: import unittest
  from .None import utils
  import numpy
  import tensorflow.compat.v1
label_desc: Use image node_id 5 for calling the UtilsTF1Test obj's underlying member method code with example usage: obj.testThreeKeysSuccess() without return types