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: Constructor.
  
  Args:
      validation_data (Tuple[np.ndarray, Optional[np.ndarray]]): Validation data
          to perform the method on. Tuple containing (x, y).
      class_index (int): Index of targeted class
      num_samples (int): Number of noisy samples to generate for each input image
docstr_tok: ["Constructor",".","Args",":","validation_data","(","Tuple","[","np.ndarray",",","Optional","[","np.ndarray","]","]",")",":","Validation","data","to","perform","the","method","on",".","Tuple","containing","(","x",",","y",")",".","class_index","(","int",")",":","Index","of","targeted","class","num_samples","(","int",")",":","Number","of","noisy","samples","to","generate","for","each","input","image"]
code: def __init__(self, validation_data, class_index, output_dir=None):
      """
      Constructor.
  
      Args:
          validation_data (Tuple[np.ndarray, Optional[np.ndarray]]): Validation data
              to perform the method on. Tuple containing (x, y).
          class_index (int): Index of targeted class
          num_samples (int): Number of noisy samples to generate for each input image
      """
      super().__init__()
      self.validation_data = validation_data
      self.class_index = class_index
      if not output_dir:
          output_dir = Path("./logs") / self.default_output_subdir
      self.output_dir = Path(output_dir) / datetime.now().strftime(
          "%Y%m%d-%H%M%S.%f"
      )
      Path.mkdir(Path(self.output_dir), parents=True, exist_ok=True)
  
      self.file_writer = tf.summary.create_file_writer(
          str(self.output_dir)
      )
      self.score_model = None
  
file_path: tf-explain/tf_explain/callbacks/vanilla_gradients.py
imports: from datetime import datetime
  from pathlib import Path
  import numpy
  import tensorflow
  from tensorflow.keras.callbacks import Callback
  from tf_explain.core.vanilla_gradients import VanillaGradients
label_desc: Use image node_id 1 to create a new VanillaGradientsCallback object from inherited base classes: Callback with example: obj = VanillaGradientsCallback(validation_data, class_index, output_dir)