class_docstr: Perform gradients backpropagation for a given input
  
  Paper: [Deep Inside Convolutional Networks: Visualising Image Classification
      Models and Saliency Maps](https://arxiv.org/abs/1312.6034)
class_docstr_tok: ["Perform","gradients","backpropagation","for","a","given","input","Paper",":","[","Deep","Inside","Convolutional","Networks",":","Visualising","Image","Classification","Models","and","Saliency","Maps","]","(","https",":","\/\/arxiv.org\/abs\/1312.6034",")"]
docstr: Perform gradients backpropagation for a given input
  
  Args:
      validation_data (Tuple[np.ndarray, Optional[np.ndarray]]): Validation data
          to perform the method on. Tuple containing (x, y).
      model (tf.keras.Model): tf.keras model to inspect. The last two layers of
          the model should be: a layer which computes class scores with no
          activation, followed by an activation layer. This is to enable the
          gradient calculation to bypass the final activation and calculate
          the gradient of the score instead.
      class_index (int): Index of targeted class
  
  Returns:
      numpy.ndarray: Grid of all the gradients
docstr_tok: ["Perform","gradients","backpropagation","for","a","given","input","Args",":","validation_data","(","Tuple","[","np.ndarray",",","Optional","[","np.ndarray","]","]",")",":","Validation","data","to","perform","the","method","on",".","Tuple","containing","(","x",",","y",")",".","model","(","tf.keras.Model",")",":","tf.keras","model","to","inspect",".","The","last","two","layers","of","the","model","should","be",":","a","layer","which","computes","class","scores","with","no","activation",",","followed","by","an","activation","layer",".","This","is","to","enable","the","gradient","calculation","to","bypass","the","final","activation","and","calculate","the","gradient","of","the","score","instead",".","class_index","(","int",")",":","Index","of","targeted","class","Returns",":","numpy.ndarray",":","Grid","of","all","the","gradients"]
code: def explain(self, validation_data, model, class_index):
      """
      Perform gradients backpropagation for a given input
  
      Args:
          validation_data (Tuple[np.ndarray, Optional[np.ndarray]]): Validation data
              to perform the method on. Tuple containing (x, y).
          model (tf.keras.Model): tf.keras model to inspect. The last two layers of
              the model should be: a layer which computes class scores with no
              activation, followed by an activation layer. This is to enable the
              gradient calculation to bypass the final activation and calculate
              the gradient of the score instead.
          class_index (int): Index of targeted class
  
      Returns:
          numpy.ndarray: Grid of all the gradients
      """
      score_model = self.get_score_model(model)
      return self.explain_score_model(
          validation_data, score_model, class_index
      )
  
file_path: tf-explain/tf_explain/core/vanilla_gradients.py
imports: from warnings import warn
  import tensorflow
  from tf_explain.utils.display import grid_display
  from tf_explain.utils.image import transform_to_normalized_grayscale
  from tf_explain.utils.saver import save_grayscale
label_desc: Use image node_id 1 for calling the VanillaGradients obj's underlying member method code with example usage: obj.explain(validation_data, model, class_index) and returns: self