You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
warning with tf.losses.softmax_cross_entropy #16534
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.
.../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.
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?
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?
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.
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)
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?
Activity
drpngx commentedon Jan 30, 2018
Can you print out the exact message and you expected?
yaohualibin commentedon Jan 30, 2018
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.
drpngx commentedon Jan 30, 2018
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?
yongtang commentedon Feb 7, 2018
Added #16837 for the fix.
GPhilo commentedon Feb 13, 2018
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?martinwicke commentedon Feb 23, 2018
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.
GPhilo commentedon Feb 25, 2018
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)
VishalVaddina commentedon Mar 5, 2018
@GPhilo
Found a couple of use-cases here; Interesting.
Androbin commentedon May 18, 2018
It seams odd to me, that going forward, there will be like
tf.nn.foo_v2but notf.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?