Skip to content

warning with tf.losses.softmax_cross_entropy #16534

Closed

Description

@yaohualibin

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): No
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows and Linux Ubuntu 16.04
  • TensorFlow installed from (source or binary): binary
  • TensorFlow version (use command below): 1.5
  • Python version: 3.6
  • Bazel version (if compiling from source): N/A
  • GCC/Compiler version (if compiling from source): N/A
  • CUDA/cuDNN version: 9/7
  • GPU model and memory:
  • Exact command to reproduce:

Describe the problem

tf.losses.softmax_cross_entropy calls tf.nn.softmax_cross_entropy_with_logits, in which there is a warning. It's better also provide tf.losses.softmax_cross_entropy_v2 to call tf.nn.softmax_cross_entropy_with_logits_v2.

Activity

  1. drpngx commented on Jan 30, 2018

    @drpngx
    Contributor

    Can you print out the exact message and you expected?

  2. added
    stat:awaiting response
    on Jan 30, 2018
  3. yaohualibin commented on Jan 30, 2018

    @yaohualibin
    Author

    The warning message reported is

    .../lib/python3.6/site-packages/tensorflow/python/ops/losses/losses_impl.py:691: softmax_cross_entropy_with_logits (from tensorflow.python.ops.nn_ops) is deprecated and will be removed in a future version.
    Instructions for updating:

    Future major versions of TensorFlow will allow gradients to flow
    into the labels input on backprop by default.

    See tf.nn.softmax_cross_entropy_with_logits_v2.

    I didn't call tf.nn.softmax_cross_entropy_with_logits directly. It was called by tf.losses.softmax_cross_entropy. It's better also provide tf.losses.softmax_cross_entropy_v2 to call tf.nn.softmax_cross_entropy_with_logits_v2 to silence the warning.

  4. drpngx commented on Jan 30, 2018

    @drpngx
    Contributor

    OK, yes, that's a problem in our deprecation. The solution is to refactor the code to call a function that doesn't have the deprecated code. Would you be willing to send a PR for that?

  5. removed
    stat:awaiting response
    on Feb 6, 2018
  6. added
    stat:contribution welcome
    on Feb 6, 2018
  7. yongtang commented on Feb 7, 2018

    @yongtang
    Member

    Added #16837 for the fix.

  8. GPhilo commented on Feb 13, 2018

    @GPhilo

    Jumping in because of a doubt: what exactly does "allow gradients to flow
    into the labels input on backprop by default" mean?

    I see in the merged PR that it's now necessary to include the call to stop_gradients, but what would happen if that call was missing? And what is the rationale behind letting gradients flow into the labels input?

  9. martinwicke commented on Feb 23, 2018

    @martinwicke
    Member

    If the call was missing, gradients would be propagated to the labels, which, depending on where those labels come from, may or may not be what you want.

    In general, gradients should flow through all ops back to all inputs. If you do not want this, stop_gradients should be used.

  10. GPhilo commented on Feb 25, 2018

    @GPhilo

    Thanks for the clarification.
    Is there anywhere an example of use-case where propagation to labels is useful/necessary? (I'm just trying to figure out what is this used for)

  11. VishalVaddina commented on Mar 5, 2018

    @VishalVaddina

    @GPhilo
    Found a couple of use-cases here; Interesting.

  12. Androbin commented on May 18, 2018

    @Androbin
    Contributor

    It seams odd to me, that going forward, there will be like tf.nn.foo_v2 but no tf.nn.foo...
    I suppose this is a matter of compatibility, but since (according to the message) this will take effect in the next major release, why can't we keep the name?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stat:contribution welcome

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions