class_docstr: To run: "python -m saliency.tf1.blur_ig_test" top-level saliency directory.
class_docstr_tok: ["To","run",":","``","python","-m","saliency.tf1.blur_ig_test","''","top-level","saliency","directory","."]
code: def setUp(self):
      super().setUp()
      self.max_sigma = 10
      with tf.Graph().as_default() as graph:
          self.x = tf.placeholder(
              shape=[None, 5, 5, 1], dtype=tf.float32
          )
          y = tf.sin(self.x)
          y_sum = tf.reduce_sum(y, [1, 2, 3])
          self.gradients_node = tf.gradients(y, self.x)[0]
          self.sess = tf.Session(graph=graph)
          self.sess_spy = mock.MagicMock(wraps=self.sess)
          # All black except 2 pixels near the center.
          self.x_input_val = np.array(
              [
                  [0.0, 0.0, 0.0, 0.0, 0.0],
                  [0.0, 0.5, 0.0, 0.0, 0.0],
                  [0.0, 0.0, 1.0, 0.0, 0.0],
                  [0.0, 0.0, 0.0, 0.0, 0.0],
                  [0.0, 0.0, 0.0, 0.0, 0.0],
              ],
              dtype=float,
          )
          self.x_input_val = self.x_input_val.reshape((5, 5, 1))
          # Calculate the value of `y` at the input.
          y_input_val = self.sess.run(
              y, feed_dict={self.x: [self.x_input_val]}
          )
  
          # Baseline is the fully blurred version of the input.
          x_baseline_val = gaussian_filter(
              self.x_input_val,
              sigma=[self.max_sigma, self.max_sigma, 0],
              mode="constant",
          )
          y_baseline_val = self.sess.run(
              y, feed_dict={self.x: [x_baseline_val]}
          )
  
          # The expected BlurIG value is equal to the difference between
          # the `y` value at the input and the `y` value at the baseline. Because
          # each value is independent, we can calculate the expected blur_ig value
          # of each.
          #
          # Expected: [[-0, -0, -0, -0, -0],
          #            [-0, 0.641, -0, -0, -0],
          #            [-0, -0, 0.838, -0, -0],
          #            [-0, -0, -0, -0, -0],
          #            [-0, -0, -0, -0, -0]
          self.expected_val = y_input_val[0] - y_baseline_val[0]
          self.blur_ig_instance = blur_ig.BlurIG(
              graph, self.sess_spy, y_sum, self.x
          )
  
file_path: saliency/saliency/tf1/blur_ig_test.py
imports: import unittest
  import unittest.mock
  from .None import blur_ig
  import numpy
  from scipy.ndimage import gaussian_filter
  import tensorflow.compat.v1
label_desc: Use image node_id 1 for calling the BlurIgTest obj's underlying member method code with example usage: obj.setUp() without return types