(labels, weights, logits)
return metrics
Returns a map of metric names to metric tensors for generative task.

  Args:
    labels: tensor of [batch_size, seq_len].
    weights: tensor of [batch_size, seq_len].
    logits: tensor of [batch_size, seq_len, vocab_size].

  Returns:
    dictionary of tensor metrics.
Returns a map of metric names to metric tensors for generative task.
Returns a map of metric names to metric tensors for generative task .
def _create_generative_metrics(labels, weights, logits):
  """Returns a map of metric names to metric tensors for generative task.

  Args:
    labels: tensor of [batch_size, seq_len].
    weights: tensor of [batch_size, seq_len].
    logits: tensor of [batch_size, seq_len, vocab_size].

  Returns:
    dictionary of tensor metrics.
  """
  predictions = tf.argmax(logits, -1)
  accuracy_unmasked = tf.metrics.accuracy(
      labels=labels, predictions=predictions)
  accuracy_pad_masked = tf.metrics.accuracy(
      labels=labels, predictions=predictions, weights=weights)
  loss = tf.losses.sparse_softmax_cross_entropy(labels, logits, weights=weights)
  metrics = {
      "metrics/accuracy_unmasked": accuracy_unmasked,
      "metrics/accuracy_pad_masked": accuracy_pad_masked,
      "metrics/perplexity_pad_masked": tf.metrics.mean(loss),
  }
  return metrics
def _create_generative_metrics ( labels , weights , logits ) : predictions = tf . argmax ( logits , - 1 ) accuracy_unmasked = tf . metrics . accuracy ( labels = labels , predictions = predictions ) accuracy_pad_masked = tf . metrics . accuracy ( labels = labels , predictions = predictions , weights = weights ) loss = tf . losses . sparse_softmax_cross_entropy ( labels , logits , weights = weights ) metrics = { "metrics/accuracy_unmasked" : accuracy_unmasked , "metrics/accuracy_pad_masked" : accuracy_pad_masked , "metrics/perplexity_pad_masked" : tf . metrics . mean ( loss ) , } return metrics