class_docstr: Perform Grad CAM algorithm for a given input
  
  Paper: [Grad-CAM: Visual Explanations from Deep Networks
          via Gradient-based Localization](https://arxiv.org/abs/1610.02391)
class_docstr_tok: ["Perform","Grad","CAM","algorithm","for","a","given","input","Paper",":","[","Grad-CAM",":","Visual","Explanations","from","Deep","Networks","via","Gradient-based","Localization","]","(","https",":","\/\/arxiv.org\/abs\/1610.02391",")"]
docstr: Apply Grad CAM algorithm scheme.
  
  Inputs are the convolutional outputs (shape WxHxN) and gradients (shape WxHxN).
  From there:
      - we compute the spatial average of the gradients
      - we build a ponderated sum of the convolutional outputs based on those averaged weights
  
  Args:
      output (tf.Tensor): Target layer outputs, with shape (batch_size, Hl, Wl, Nf),
          where Hl and Wl are the target layer output height and width, and Nf the
          number of filters.
      grads (tf.Tensor): Guided gradients with shape (batch_size, Hl, Wl, Nf)
  
  Returns:
      List[tf.Tensor]: List of ponderated output of shape (batch_size, Hl, Wl, 1)
docstr_tok: ["Apply","Grad","CAM","algorithm","scheme",".","Inputs","are","the","convolutional","outputs","(","shape","WxHxN",")","and","gradients","(","shape","WxHxN",")",".","From","there",":","-","we","compute","the","spatial","average","of","the","gradients","-","we","build","a","ponderated","sum","of","the","convolutional","outputs","based","on","those","averaged","weights","Args",":","output","(","tf.Tensor",")",":","Target","layer","outputs",",","with","shape","(","batch_size",",","Hl",",","Wl",",","Nf",")",",","where","Hl","and","Wl","are","the","target","layer","output","height","and","width",",","and","Nf","the","number","of","filters",".","grads","(","tf.Tensor",")",":","Guided","gradients","with","shape","(","batch_size",",","Hl",",","Wl",",","Nf",")","Returns",":","List","[","tf.Tensor","]",":","List","of","ponderated","output","of","shape","(","batch_size",",","Hl",",","Wl",",","1",")"]
code: def generate_ponderated_output(outputs, grads):
      """
      Apply Grad CAM algorithm scheme.
  
      Inputs are the convolutional outputs (shape WxHxN) and gradients (shape WxHxN).
      From there:
          - we compute the spatial average of the gradients
          - we build a ponderated sum of the convolutional outputs based on those averaged weights
  
      Args:
          output (tf.Tensor): Target layer outputs, with shape (batch_size, Hl, Wl, Nf),
              where Hl and Wl are the target layer output height and width, and Nf the
              number of filters.
          grads (tf.Tensor): Guided gradients with shape (batch_size, Hl, Wl, Nf)
  
      Returns:
          List[tf.Tensor]: List of ponderated output of shape (batch_size, Hl, Wl, 1)
      """
  
      maps = [
          GradCAM.ponderate_output(output, grad)
          for output, grad in zip(outputs, grads)
      ]
  
      return maps
  
file_path: tf-explain/tf_explain/core/grad_cam.py
imports: import numpy
  import tensorflow
  import cv2
  from tf_explain.utils.display import grid_display, heatmap_display
  from tf_explain.utils.saver import save_rgb
label_desc: Use image node_id 4 for calling the GradCAM obj's underlying member method code with example usage: obj.generate_ponderated_output(outputs, grads) and returns: maps