class_docstr: Abstract loss function for KG embeddings.
docstr: Initialize KG loss function.
  
  Args:
    sizes: Tuple of size 3 containing (n_entities, n_rels, n_entities).
    neg_sample_size: Integer indicating the number of negative samples to use.
docstr_tok: ["Initialize","KG","loss","function",".","Args",":","sizes",":","Tuple","of","size","3","containing","(","n_entities",",","n_rels",",","n_entities",")",".","neg_sample_size",":","Integer","indicating","the","number","of","negative","samples","to","use","."]
code: def __init__(self, sizes, neg_sample_size):
      """Initialize KG loss function.
  
      Args:
        sizes: Tuple of size 3 containing (n_entities, n_rels, n_entities).
        neg_sample_size: Integer indicating the number of negative samples to use.
      """
      self.n_entities = sizes[0]
      self.n_predicates = sizes[1]
      self.neg_sample_size = neg_sample_size
      self.use_neg_sampling = neg_sample_size > 0
      self.gamma = tf.Variable(
          self.neg_sample_size
          * tf.keras.backend.ones(1)
          / self.n_entities,
          trainable=False,
      )
  
file_path: neural-structured-learning/research/kg_hyp_emb/learning/losses.py
imports: import abc
  import tensorflow
label_desc: Use image node_id 1 to create a new LossFn object from inherited base classes: abc with example: obj = LossFn(sizes, neg_sample_size)