parameters: (op, grad_softmax)
return_statement: return grad_x
docstring: The derivative of the softmax nonlinearity.
  
    We assume that probs is of shape [batch_size * dim]
    The formula for dsoftmax / dx = (diag(softmax) - softmax * softmax').
    This matrix is diagonal minus a rank one matrix, so it is easy to implement
    as follows:
  
      grad_x = grad_softmax * softmax - sum(grad_softmax * softmax) * softmax
  
    Args:
       op: the Softmax op.
       grad_softmax:  the tensor representing the gradient w.r.t. the
         softmax output.
  
    Returns:
       gradient w.r.t the input to the softmax
docstring_summary: The derivative of the softmax nonlinearity.
docstring_tokens: The derivative of the softmax nonlinearity .
function: def _SoftmaxGrad(op, grad_softmax):
    """The derivative of the softmax nonlinearity.
  
    We assume that probs is of shape [batch_size * dim]
    The formula for dsoftmax / dx = (diag(softmax) - softmax * softmax').
    This matrix is diagonal minus a rank one matrix, so it is easy to implement
    as follows:
  
      grad_x = grad_softmax * softmax - sum(grad_softmax * softmax) * softmax
  
    Args:
       op: the Softmax op.
       grad_softmax:  the tensor representing the gradient w.r.t. the
         softmax output.
  
    Returns:
       gradient w.r.t the input to the softmax
  
    """
    # TODO(ilyasu): assert that the tensor has two dimensions at
    # graph-construction time?  Alternatively: do different things
    # depending on the dimensionality of the input tensors.
    softmax = op.outputs[0]
    grad_x = ((grad_softmax - array_ops.reshape(
        math_ops.reduce_sum(grad_softmax * softmax, [1]), [-1, 1])) * softmax)
    return grad_x
function_tokens: def _SoftmaxGrad ( op , grad_softmax ) : # TODO(ilyasu): assert that the tensor has two dimensions at # graph-construction time?  Alternatively: do different things # depending on the dimensionality of the input tensors. softmax = op . outputs [ 0 ] grad_x = ( ( grad_softmax - array_ops . reshape ( math_ops . reduce_sum ( grad_softmax * softmax , [ 1 ] ) , [ - 1 , 1 ] ) ) * softmax ) return grad_x