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: Perform the ponderation of filters output with respect to average of gradients values.
  
  Args:
      output (tf.Tensor): Target layer outputs, with shape (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 (Hl, Wl, Nf)
  
  Returns:
      tf.Tensor: Ponderated output of shape (Hl, Wl, 1)
docstr_tok: ["Perform","the","ponderation","of","filters","output","with","respect","to","average","of","gradients","values",".","Args",":","output","(","tf.Tensor",")",":","Target","layer","outputs",",","with","shape","(","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","(","Hl",",","Wl",",","Nf",")","Returns",":","tf.Tensor",":","Ponderated","output","of","shape","(","Hl",",","Wl",",","1",")"]
code: def ponderate_output(output, grad):
      """
      Perform the ponderation of filters output with respect to average of gradients values.
  
      Args:
          output (tf.Tensor): Target layer outputs, with shape (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 (Hl, Wl, Nf)
  
      Returns:
          tf.Tensor: Ponderated output of shape (Hl, Wl, 1)
      """
      weights = tf.reduce_mean(grad, axis=(0, 1))
  
      # Perform ponderated sum : w_i * output[:, :, i]
      cam = tf.reduce_sum(tf.multiply(weights, output), axis=-1)
  
      return cam
  
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 5 for calling the GradCAM obj's underlying member method code with example usage: obj.ponderate_output(output, grad) and returns: cam