parameters: (logits, labels)
return_statement: return loss, dlogits
docstring: Calculates softmax cross entropy loss.
  
    Reference on softmax cross entropy:
      http://cs231n.github.io/linear-classify/#softmax
    Reference on getting gradient of softmax cross entropy:
      https://deepnotes.io/softmax-crossentropy
  
    Args:
      logits: NxC ndarray, unnormalized logits
      labels: length N ndarray, index of class label in one hot vector.
  
    Returns:
      A tuple of Cross-entropy loss and gradient with respect to logits
docstring_summary: Calculates softmax cross entropy loss.
docstring_tokens: Calculates softmax cross entropy loss .
function: def softmax_cross_entropy_loss(logits, labels):
    """Calculates softmax cross entropy loss.
  
    Reference on softmax cross entropy:
      http://cs231n.github.io/linear-classify/#softmax
    Reference on getting gradient of softmax cross entropy:
      https://deepnotes.io/softmax-crossentropy
  
    Args:
      logits: NxC ndarray, unnormalized logits
      labels: length N ndarray, index of class label in one hot vector.
  
    Returns:
      A tuple of Cross-entropy loss and gradient with respect to logits
    """
    # Use softmax(x) = softmax(x-C) to avoid exp() overflow.
    logits -= np.max(logits, axis=1, keepdims=True)
    probs = np.exp(logits)
    probs /= np.sum(probs, axis=1, keepdims=True)
    num_input = logits.shape[0]
    loss = -np.sum(np.log(probs[range(num_input), labels])) / num_input
  
    dlogits = probs.copy()
    dlogits[range(num_input), labels] -= 1
    dlogits /= num_input
    return loss, dlogits
function_tokens: def softmax_cross_entropy_loss ( logits , labels ) : # Use softmax(x) = softmax(x-C) to avoid exp() overflow. logits -= np . max ( logits , axis = 1 , keepdims = True ) probs = np . exp ( logits ) probs /= np . sum ( probs , axis = 1 , keepdims = True ) num_input = logits . shape [ 0 ] loss = - np . sum ( np . log ( probs [ range ( num_input ) , labels ] ) ) / num_input dlogits = probs . copy ( ) dlogits [ range ( num_input ) , labels ] -= 1 dlogits /= num_input return loss , dlogits