aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar ngc92 <ngc92@users.noreply.github.com>2017-12-26 20:23:05 +0100
committerGravatar drpngx <drpngx@users.noreply.github.com>2017-12-26 11:23:05 -0800
commitb1ffd57fde26dce0aca1f8f2243a9a4a2abb994a (patch)
tree0c0823dfd8e7cef44f77c98ee98df8d264e6bc92
parentd72d5b07bfd212adbfadb748c3dab5d56ec2fb9f (diff)
added note about weights gradient in compute_weighted_loss (#15533)
-rw-r--r--tensorflow/python/ops/losses/losses_impl.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/tensorflow/python/ops/losses/losses_impl.py b/tensorflow/python/ops/losses/losses_impl.py
index b74971f654..4f24c3c5bf 100644
--- a/tensorflow/python/ops/losses/losses_impl.py
+++ b/tensorflow/python/ops/losses/losses_impl.py
@@ -157,6 +157,13 @@ def compute_weighted_loss(
ValueError: If `weights` is `None` or the shape is not compatible with
`losses`, or if the number of dimensions (rank) of either `losses` or
`weights` is missing.
+
+ Note:
+ When calculating the gradient of a weighted loss contributions from
+ both `losses` and `weights` are considered. If your `weights` depend
+ on some model parameters but you do not want this to affect the loss
+ gradient, you need to apply @{tf.stop_gradient} to `weights` before
+ passing them to `compute_weighted_loss`.
"""
Reduction.validate(reduction)
with ops.name_scope(scope, "weighted_loss", (losses, weights)):