parameters: (output, target, from_logits=False)
docstring: Categorical crossentropy with integer targets.
  
    Arguments:
        output: A tensor resulting from a softmax
            (unless `from_logits` is True, in which
            case `output` is expected to be the logits).
        target: An integer tensor.
        from_logits: Boolean, whether `output` is the
            result of a softmax, or is a tensor of logits.
  
    Returns:
        Output tensor.
docstring_summary: Categorical crossentropy with integer targets.
docstring_tokens: Categorical crossentropy with integer targets .
function: def sparse_categorical_crossentropy(output, target, from_logits=False):
    """Categorical crossentropy with integer targets.
  
    Arguments:
        output: A tensor resulting from a softmax
            (unless `from_logits` is True, in which
            case `output` is expected to be the logits).
        target: An integer tensor.
        from_logits: Boolean, whether `output` is the
            result of a softmax, or is a tensor of logits.
  
    Returns:
        Output tensor.
    """
    # Note: nn.sparse_softmax_cross_entropy_with_logits
    # expects logits, Keras expects probabilities.
    if not from_logits:
      epsilon = _to_tensor(_EPSILON, output.dtype.base_dtype)
      output = clip_ops.clip_by_value(output, epsilon, 1 - epsilon)
      output = math_ops.log(output)
  
    output_shape = output.get_shape()
    targets = cast(flatten(target), 'int64')
    logits = array_ops.reshape(output, [-1, int(output_shape[-1])])
    res = nn.sparse_softmax_cross_entropy_with_logits(
        labels=targets, logits=logits)
    if len(output_shape) == 3:
      # if our output includes timesteps we need to reshape
      return array_ops.reshape(res, array_ops.shape(output)[:-1])
    else:
      return res
function_tokens: def sparse_categorical_crossentropy ( output , target , from_logits = False ) : # Note: nn.sparse_softmax_cross_entropy_with_logits # expects logits, Keras expects probabilities. if not from_logits : epsilon = _to_tensor ( _EPSILON , output . dtype . base_dtype ) output = clip_ops . clip_by_value ( output , epsilon , 1 - epsilon ) output = math_ops . log ( output ) output_shape = output . get_shape ( ) targets = cast ( flatten ( target ) , 'int64' ) logits = array_ops . reshape ( output , [ - 1 , int ( output_shape [ - 1 ] ) ] ) res = nn . sparse_softmax_cross_entropy_with_logits ( labels = targets , logits = logits ) if len ( output_shape ) == 3 : # if our output includes timesteps we need to reshape return array_ops . reshape ( res , array_ops . shape ( output ) [ : - 1 ] ) else : return res