class_docstr: Self Adversarial Sampling loss.
  
  Introduced in :cite:`sun2018rotate`.
  
  .. math::
  
      \mathcal{L} = -log \left( \sigma(\gamma + f_{model} (\mathbf{s},\mathbf{o})) \right)
      - \sum_{i=1}^{n} p(h'_{i}, r, t'_{i} ) \cdot log
      \left( \sigma(-f_{model}(\mathbf{s}'_{i},\mathbf{o}'_{i}) - \gamma) \right)
  
  where :math:`\mathbf{s}, \mathbf{o} \in \mathcal{R}^k` are the embeddings of the subject
  and object of a triple :math:`t=(s,r,o)`, :math:`\gamma \in \mathbb{R}` is the margin, :math:`\sigma` the sigmoid
  function, and :math:`p(s'_{i}, r, o'_{i})` is the negatives sampling distribution which is defined as:
  
  .. math::
  
      p(s'_j, r, o'_j | \{(s_i, r_i, o_i)\}) = \frac{\exp \left( \alpha \, f_{model}(\mathbf{s'_j}, \mathbf{o'_j}) \right)}
      {\sum_i \exp \left( \alpha \, f_{model}(\mathbf{s'_i}, \mathbf{o'_i}) \right)}
  
  where :math:`\alpha` is the temperature of sampling and :math:`f_{model}` is the scoring function of
  the desired embedding model.
  
  Example
  -------
  >>> import ampligraph.latent_features.loss_functions as lfs
  >>> loss = lfs.SelfAdversarialLoss({'margin': 1, 'alpha': 0.1, 'reduction': 'mean'})
  >>> isinstance(loss, lfs.SelfAdversarialLoss)
  True
  
  >>> loss = lfs.get('self_adversarial')
  >>> isinstance(loss, lfs.SelfAdversarialLoss)
  True
class_docstr_tok: ["Self","Adversarial","Sampling","loss",".","Introduced","in",":","cite",":","`","sun2018rotate","`",".","..","math",":",":","\\mathcal","{","L","}","=","-log","\\left","(","\\sigma","(","\\gamma","+","f_","{","model","}","(","\\mathbf","{","s","}",",","\\mathbf","{","o","}",")",")","\\right",")","-","\\sum_","{","i=1","}","^","{","n","}","p","(","h","'","_","{","i","}",",","r",",","t","'","_","{","i","}",")","\\cdot","log","\\left","(","\\sigma","(","-f_","{","model","}","(","\\mathbf","{","s","}","'","_","{","i","}",",","\\mathbf","{","o","}","'","_","{","i","}",")","-","\\gamma",")","\\right",")","where",":","math",":","`","\\mathbf","{","s","}",",","\\mathbf","{","o","}","\\in","\\mathcal","{","R","}","^k","`","are","the","embeddings","of","the","subject","and","object","of","a","triple",":","math",":","`","t=","(","s",",","r",",","o",")","`",",",":","math",":","`","\\gamma","\\in","\\mathbb","{","R","}","`","is","the","margin",",",":","math",":","`","\\sigma","`","the","sigmoid","function",",","and",":","math",":","`","p","(","s","'","_","{","i","}",",","r",",","o","'","_","{","i","}",")","`","is","the","negatives","sampling","distribution","which","is","defined","as",":","..","math",":",":","p","(","s'_j",",","r",",","o'_j","|","\\","{","(","s_i",",","r_i",",","o_i",")","\\","}",")","=","\\frac","{","\\exp","\\left","(","\\alpha","\\",",","f_","{","model","}","(","\\mathbf","{","s'_j","}",",","\\mathbf","{","o'_j","}",")","\\right",")","}","{","\\sum_i","\\exp","\\left","(","\\alpha","\\",",","f_","{","model","}","(","\\mathbf","{","s'_i","}",",","\\mathbf","{","o'_i","}",")","\\right",")","}","where",":","math",":","`","\\alpha","`","is","the","temperature","of","sampling","and",":","math",":","`","f_","{","model","}","`","is","the","scoring","function","of","the","desired","embedding","model",".","Example","--","--","--","-",">",">",">","import","ampligraph.latent_features.loss_functions","as","lfs",">",">",">","loss","=","lfs.SelfAdversarialLoss","(","{","'margin","'",":","1",",","'alpha","'",":","0.1",",","'reduction","'",":","'mean","'","}",")",">",">",">","isinstance","(","loss",",","lfs.SelfAdversarialLoss",")","True",">",">",">","loss","=","lfs.get","(","'self_adversarial","'",")",">",">",">","isinstance","(","loss",",","lfs.SelfAdversarialLoss",")","True"]
docstr: Initializes the hyperparameters needed by the algorithm.
  
  Parameters
  ----------
  hyperparam_dict : dict
      The Loss will check the keys to get the corresponding parameters.
  
      - `"margin"`` (int) - Margin to be used in adversarial loss computation (default: 3).
      - `"alpha"`: (float) - Temperature of sampling (default: 0.5).
docstr_tok: ["Initializes","the","hyperparameters","needed","by","the","algorithm",".","Parameters","--","--","--","--","--","hyperparam_dict",":","dict","The","Loss","will","check","the","keys","to","get","the","corresponding","parameters",".","-","`","``","margin","''","``","(","int",")","-","Margin","to","be","used","in","adversarial","loss","computation","(","default",":","3",")",".","-","`","``","alpha","''","`",":","(","float",")","-","Temperature","of","sampling","(","default",":","0.5",")","."]
code: def _init_hyperparams(self, hyperparam_dict={}):
      """Initializes the hyperparameters needed by the algorithm.
  
      Parameters
      ----------
      hyperparam_dict : dict
          The Loss will check the keys to get the corresponding parameters.
  
          - `"margin"`` (int) - Margin to be used in adversarial loss computation (default: 3).
          - `"alpha"`: (float) - Temperature of sampling (default: 0.5).
      """
      self._loss_parameters["margin"] = hyperparam_dict.get(
          "margin", DEFAULT_MARGIN_ADVERSARIAL
      )
      self._loss_parameters["alpha"] = hyperparam_dict.get(
          "alpha", DEFAULT_ALPHA_ADVERSARIAL
      )
  
imports: import abc
  import logging
  import six
  import tensorflow
  from tensorflow.python.keras import metrics
  from tensorflow.python.keras.utils import losses_utils
  from tensorflow.python.ops import math_ops
label_desc: Use image node_id 2 for calling the SelfAdversarialLoss obj's underlying member method code with example usage: obj._init_hyperparams(hyperparam_dict) without return types