class_docstr: Abstract loss function for KG embeddings.
docstr: Generates negative sampling mask.
  
  Args:
    logits: Tensor of size batch_size x n_entities containing predictions.
    full_labels: Tensor of size batch_size x n_entities containing one-hot
      labels.
  
  Returns:
    neg_sample_mask: Tensor of size batch_size x n_entities with ones and
                     zeros (one indicates that the corresonding example
                     is masked).
docstr_tok: ["Generates","negative","sampling","mask",".","Args",":","logits",":","Tensor","of","size","batch_size","x","n_entities","containing","predictions",".","full_labels",":","Tensor","of","size","batch_size","x","n_entities","containing","one-hot","labels",".","Returns",":","neg_sample_mask",":","Tensor","of","size","batch_size","x","n_entities","with","ones","and","zeros","(","one","indicates","that","the","corresonding","example","is","masked",")","."]
code: def get_neg_sample_mask(self, logits, full_labels):
      """Generates negative sampling mask.
  
      Args:
        logits: Tensor of size batch_size x n_entities containing predictions.
        full_labels: Tensor of size batch_size x n_entities containing one-hot
          labels.
  
      Returns:
        neg_sample_mask: Tensor of size batch_size x n_entities with ones and
                         zeros (one indicates that the corresonding example
                         is masked).
      """
      neg_sample_mask = tf.random.uniform(
          tf.shape(logits), dtype=logits.dtype
      )
      neg_sample_mask = tf.cast(
          neg_sample_mask > self.gamma, logits.dtype
      )
      neg_sample_mask = -1e6 * tf.maximum(
          neg_sample_mask - full_labels, 0
      )
      return neg_sample_mask
  
file_path: neural-structured-learning/research/kg_hyp_emb/learning/losses.py
imports: import abc
  import tensorflow
label_desc: Use image node_id 3 for calling the LossFn obj's underlying member method code with example usage: obj.get_neg_sample_mask(logits, full_labels) and returns: neg_sample_mask