Tensorflow redundant softmax
Computing the cross entropy loss directly from logits using the `softmax_cross_entropy_with_logits` is numerically more stable than computing a softmax and then the cross entropy. The improvement comes from the internal use of the log-sum-exp trick.
def tensorflow_redundant_softmax_noncompliant():
    import tensorflow as tf
    logits = [[4.0, 2.0, 1.0], [0.0, 5.0, 1.0]]
    labels = [[1.0, 0.0, 0.0], [0.0, 0.8, 0.2]]
    # Noncompliant: using `tf.nn.softmax` with
    # `tf.nn.softmax_cross_entropy_with_logits` is redundant.
    tf.nn.softmax_cross_entropy_with_logits(
     labels=labels, logits=tf.nn.softmax(logits))
def tensorflow_redundant_softmax_compliant():
    import tensorflow as tf
    logits = [[4.0, 2.0, 1.0], [0.0, 5.0, 1.0]]
    labels = [[1.0, 0.0, 0.0], [0.0, 0.8, 0.2]]
    # Compliant: unscaled `logits` is passed directly
    # to `tf.nn.softmax_cross_entropy_with_logits`.
    tf.nn.softmax_cross_entropy_with_logits(labels=labels, logits=logits)