(label_smoothing)
return loss_fn
Returns sparse or dense loss function depending on the label_smoothing.

    Args:
      label_smoothing: weight for label smoothing

    Returns:
      a function which takes labels and predictions as arguments and returns
      a softmax loss for the selected type of labels (sparse or dense).
Returns sparse or dense loss function depending on the label_smoothing.
Returns sparse or dense loss function depending on the label_smoothing .
def get_softmax_loss_fn(label_smoothing):
  """Returns sparse or dense loss function depending on the label_smoothing.

    Args:
      label_smoothing: weight for label smoothing

    Returns:
      a function which takes labels and predictions as arguments and returns
      a softmax loss for the selected type of labels (sparse or dense).
    """
  if label_smoothing > 0:

    def loss_fn(labels, logits):
      return (tf.nn.softmax_cross_entropy_with_logits(
        logits=logits, labels=labels))
  else:

    def loss_fn(labels, logits):
      return tf.nn.sparse_softmax_cross_entropy_with_logits(
        logits=logits, labels=labels)

  return loss_fn
def get_softmax_loss_fn ( label_smoothing ) : if label_smoothing > 0 : def loss_fn ( labels , logits ) : return ( tf . nn . softmax_cross_entropy_with_logits ( logits = logits , labels = labels ) ) else : def loss_fn ( labels , logits ) : return tf . nn . sparse_softmax_cross_entropy_with_logits ( logits = logits , labels = labels ) return loss_fn