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 output layer gradients are returned correctly.
docstr_tok: ["Tests","that","output","layer","gradients","are","returned","correctly","."]
code: def testOutputGradientsSuccess(self):
      """Tests that output layer gradients are returned correctly."""
      with self.graph.as_default():
          x = tf.placeholder(shape=[None, 3], dtype=np.float32)
          y = (5 * x[:, 0] - 3 * x[:, 1] ** 2)[0]
      x_value = np.array([[0.5, 0.8, 1.0]], dtype=np.float32)
      # because x[1] is squared, gradient should be -3*2x = -3*2*0.8
      expected = np.array([[5, -3 * 2 * 0.8, 0]], dtype=np.float32)
  
      call_model_function = utils.create_tf1_call_model_function(
          self.graph, self.sess, y, x
      )
      data = call_model_function(
          x_value,
          call_model_args=None,
          expected_keys=[utils.INPUT_OUTPUT_GRADIENTS],
      )
      actual = data[utils.INPUT_OUTPUT_GRADIENTS]
  
      self.assertIsNone(
          np.testing.assert_almost_equal(expected, actual)
      )
  
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 2 for calling the UtilsTF1Test obj's underlying member method code with example usage: obj.testOutputGradientsSuccess() without return types