class_docstr: A loss function that maximizes the activation of a set of filters within a particular layer.
  
  Typically this loss is used to ask the reverse question - What kind of input image would increase the networks
  confidence, for say, dog class. This helps determine what the network might be internalizing as being the 'dog'
  image space.
  
  One might also use this to generate an input image that maximizes both 'dog' and 'human' outputs on the final
  `keras.layers.Dense` layer.
class_docstr_tok: ["A","loss","function","that","maximizes","the","activation","of","a","set","of","filters","within","a","particular","layer",".","Typically","this","loss","is","used","to","ask","the","reverse","question","-","What","kind","of","input","image","would","increase","the","networks","confidence",",","for","say",",","dog","class",".","This","helps","determine","what","the","network","might","be","internalizing","as","being","the","'dog'","image","space",".","One","might","also","use","this","to","generate","an","input","image","that","maximizes","both","'dog","'","and","'human","'","outputs","on","the","final","`","keras.layers.Dense","`","layer","."]
code: def build_loss(self):
      layer_output = self.layer.output
  
      # For all other layers it is 4
      is_dense = K.ndim(layer_output) == 2
  
      loss = 0.0
      for idx in self.filter_indices:
          if is_dense:
              loss += -K.mean(layer_output[:, idx])
          else:
              # slicer is used to deal with `channels_first` or `channels_last` image data formats
              # without the ugly conditional statements.
              loss += -K.mean(layer_output[utils.slicer[:, idx, ...]])
  
      return loss
  
file_path: keras-vis/vis/losses.py
imports: from __future__ import absolute_import
  from keras import backend
  from .utils import utils
label_desc: Use image node_id 2 for calling the ActivationMaximization obj's underlying member method code with example usage: obj.build_loss() and returns: loss