class_docstr: Base class for saliency methods. Alone, this class doesn't do anything.
class_docstr_tok: ["Base","class","for","saliency","methods",".","Alone",",","this","class","does","n't","do","anything","."]
docstr: Returns a mask that is smoothed with the SmoothGrad method.
  
  Args:
    x_value: Input ndarray.
    call_model_function: A function that interfaces with a model to return
      specific output in a dictionary when given an input and other arguments.
      Expected function signature:
      - call_model_function(x_value_batch,
                            call_model_args=None,
                            expected_keys=None):
        x_value_batch - Input for the model, given as a batch (i.e. dimension
          0 is the batch dimension, dimensions 1 through n represent a single
          input).
        call_model_args - Other arguments used to call and run the model.
        expected_keys - List of keys that are expected in the output. Possible
          keys in this list are CONVOLUTION_LAYER_VALUES,
          CONVOLUTION_OUTPUT_GRADIENTS, INPUT_OUTPUT_GRADIENTS, and
          OUTPUT_LAYER_VALUES, and are explained in detail where declared.
    call_model_args: The arguments that will be passed to the call model
      function, for every call of the model.
    stdev_spread: Amount of noise to add to the input, as fraction of the
                  total spread (x_max - x_min). Defaults to 15%.
    nsamples: Number of samples to average across to get the smooth gradient.
    magnitude: If true, computes the sum of squares of gradients instead of
               just the sum. Defaults to true.
docstr_tok: ["Returns","a","mask","that","is","smoothed","with","the","SmoothGrad","method",".","Args",":","x_value",":","Input","ndarray",".","call_model_function",":","A","function","that","interfaces","with","a","model","to","return","specific","output","in","a","dictionary","when","given","an","input","and","other","arguments",".","Expected","function","signature",":","-","call_model_function","(","x_value_batch",",","call_model_args=None",",","expected_keys=None",")",":","x_value_batch","-","Input","for","the","model",",","given","as","a","batch","(","i.e",".","dimension","0","is","the","batch","dimension",",","dimensions","1","through","n","represent","a","single","input",")",".","call_model_args","-","Other","arguments","used","to","call","and","run","the","model",".","expected_keys","-","List","of","keys","that","are","expected","in","the","output",".","Possible","keys","in","this","list","are","CONVOLUTION_LAYER_VALUES",",","CONVOLUTION_OUTPUT_GRADIENTS",",","INPUT_OUTPUT_GRADIENTS",",","and","OUTPUT_LAYER_VALUES",",","and","are","explained","in","detail","where","declared",".","call_model_args",":","The","arguments","that","will","be","passed","to","the","call","model","function",",","for","every","call","of","the","model",".","stdev_spread",":","Amount","of","noise","to","add","to","the","input",",","as","fraction","of","the","total","spread","(","x_max","-","x_min",")",".","Defaults","to","15","%",".","nsamples",":","Number","of","samples","to","average","across","to","get","the","smooth","gradient",".","magnitude",":","If","true",",","computes","the","sum","of","squares","of","gradients","instead","of","just","the","sum",".","Defaults","to","true","."]
code: def GetSmoothedMask(
      self,
      x_value,
      call_model_function,
      call_model_args=None,
      stdev_spread=0.15,
      nsamples=25,
      magnitude=True,
      **kwargs,
  ):
      """Returns a mask that is smoothed with the SmoothGrad method.
  
      Args:
        x_value: Input ndarray.
        call_model_function: A function that interfaces with a model to return
          specific output in a dictionary when given an input and other arguments.
          Expected function signature:
          - call_model_function(x_value_batch,
                                call_model_args=None,
                                expected_keys=None):
            x_value_batch - Input for the model, given as a batch (i.e. dimension
              0 is the batch dimension, dimensions 1 through n represent a single
              input).
            call_model_args - Other arguments used to call and run the model.
            expected_keys - List of keys that are expected in the output. Possible
              keys in this list are CONVOLUTION_LAYER_VALUES,
              CONVOLUTION_OUTPUT_GRADIENTS, INPUT_OUTPUT_GRADIENTS, and
              OUTPUT_LAYER_VALUES, and are explained in detail where declared.
        call_model_args: The arguments that will be passed to the call model
          function, for every call of the model.
        stdev_spread: Amount of noise to add to the input, as fraction of the
                      total spread (x_max - x_min). Defaults to 15%.
        nsamples: Number of samples to average across to get the smooth gradient.
        magnitude: If true, computes the sum of squares of gradients instead of
                   just the sum. Defaults to true.
      """
      stdev = stdev_spread * (np.max(x_value) - np.min(x_value))
  
      total_gradients = np.zeros_like(x_value, dtype=np.float32)
      for _ in range(nsamples):
          noise = np.random.normal(0, stdev, x_value.shape)
          x_plus_noise = x_value + noise
          grad = self.GetMask(
              x_plus_noise,
              call_model_function,
              call_model_args,
              **kwargs,
          )
          if magnitude:
              total_gradients += grad * grad
          else:
              total_gradients += grad
  
      return total_gradients / nsamples
  
imports: import numpy
label_desc: Use image node_id 2 for calling the CoreSaliency obj's underlying member method code with example usage: obj.GetSmoothedMask(x_value, call_model_function, call_model_args, stdev_spread, nsamples, magnitude) and returns: unknown