class_docstr: A combination loss of Soft Nearest Neighbor Loss calculated at every layer
  in the network, and standard cross entropy of the logits. Presented in
  "Analyzing and Improving Representations with the Soft Nearest Neighbor Loss"
  by Nicholas Frosst, Nicolas Papernot, and Geoffrey Hinton.
  arXiv preprint arXiv:1902.01889 (2019).
class_docstr_tok: ["A","combination","loss","of","Soft","Nearest","Neighbor","Loss","calculated","at","every","layer","in","the","network",",","and","standard","cross","entropy","of","the","logits",".","Presented","in","''","Analyzing","and","Improving","Representations","with","the","Soft","Nearest","Neighbor","Loss","''","by","Nicholas","Frosst",",","Nicolas","Papernot",",","and","Geoffrey","Hinton",".","arXiv","preprint","arXiv:1902.01889","(","2019",")","."]
docstr: Constructor.
  :param model: Model instance, the model on which to apply the loss.
  :param temperature: Temperature used for SNNL.
  :layer_names: The names of the layers at which to calculate SNNL.
                If not provided, then SNNL is applied to each internal layer.
  :factor: The balance factor between SNNL and ross Entropy. If factor is
           negative, then SNNL will be maximized.
  :optimize_temperature: Optimize temperature at each calculation to minimize
                         the loss. This makes the loss more stable.
  :cos_distance: Use cosine distance when calculating SNNL.
docstr_tok: ["Constructor",".",":","param","model",":","Model","instance",",","the","model","on","which","to","apply","the","loss",".",":","param","temperature",":","Temperature","used","for","SNNL",".",":","layer_names",":","The","names","of","the","layers","at","which","to","calculate","SNNL",".","If","not","provided",",","then","SNNL","is","applied","to","each","internal","layer",".",":","factor",":","The","balance","factor","between","SNNL","and","ross","Entropy",".","If","factor","is","negative",",","then","SNNL","will","be","maximized",".",":","optimize_temperature",":","Optimize","temperature","at","each","calculation","to","minimize","the","loss",".","This","makes","the","loss","more","stable",".",":","cos_distance",":","Use","cosine","distance","when","calculating","SNNL","."]
code: def __init__(
      self,
      model,
      temperature=100.0,
      layer_names=None,
      factor=-10.0,
      optimize_temperature=True,
      cos_distance=False,
  ):
      """Constructor.
      :param model: Model instance, the model on which to apply the loss.
      :param temperature: Temperature used for SNNL.
      :layer_names: The names of the layers at which to calculate SNNL.
                    If not provided, then SNNL is applied to each internal layer.
      :factor: The balance factor between SNNL and ross Entropy. If factor is
               negative, then SNNL will be maximized.
      :optimize_temperature: Optimize temperature at each calculation to minimize
                             the loss. This makes the loss more stable.
      :cos_distance: Use cosine distance when calculating SNNL.
      """
      CrossEntropy.__init__(self, model, smoothing=0.0)
      self.temperature = temperature
      self.factor = factor
      self.optimize_temperature = optimize_temperature
      self.cos_distance = cos_distance
      self.layer_names = layer_names
      if not layer_names:
          # omit the final layer, the classification layer
          self.layer_names = model.get_layer_names()[:-1]
  
imports: import copy
  import json
  import os
  import warnings
  import numpy
  import tensorflow
  from cleverhans.attacks import Attack
  from cleverhans.compat import softmax_cross_entropy_with_logits
  from cleverhans.model import Model
  from cleverhans.utils import safe_zip
label_desc: Use image node_id 1 to create a new SNNLCrossEntropy object from inherited base classes: CrossEntropy with example: obj = SNNLCrossEntropy(model, temperature, layer_names, factor, optimize_temperature, cos_distance)