diff options
author | A. Unique TensorFlower <gardener@tensorflow.org> | 2018-10-04 06:09:42 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-10-04 06:14:08 -0700 |
commit | 82ea80b979768c7fe1daa4b50cf054e5a0968f31 (patch) | |
tree | 11d36ac98c1f6b3e4d3e8335188d33cf4a32161d /tensorflow/tools | |
parent | 2c9369c8d878c913b5dfcd3c27849bcd3d6af6c9 (diff) |
Add option in tf.gradients() to return zero tensors for unconnected gradients.
tf.gradients currently returns [NONE] when the gradient of unconnected variables
is required. This backwards compatable change adds in the option to have zero
tensors returned that match the dimensions of the input tensor.
PiperOrigin-RevId: 215725488
Diffstat (limited to 'tensorflow/tools')
4 files changed, 34 insertions, 2 deletions
diff --git a/tensorflow/tools/api/golden/v1/tensorflow.-unconnected-gradients.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-unconnected-gradients.pbtxt new file mode 100644 index 0000000000..c5eb959430 --- /dev/null +++ b/tensorflow/tools/api/golden/v1/tensorflow.-unconnected-gradients.pbtxt @@ -0,0 +1,12 @@ +path: "tensorflow.UnconnectedGradients" +tf_class { + is_instance: "<enum \'UnconnectedGradients\'>" + member { + name: "NONE" + mtype: "<enum \'UnconnectedGradients\'>" + } + member { + name: "ZERO" + mtype: "<enum \'UnconnectedGradients\'>" + } +} diff --git a/tensorflow/tools/api/golden/v1/tensorflow.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.pbtxt index a268529c1f..c1cc7322f0 100644 --- a/tensorflow/tools/api/golden/v1/tensorflow.pbtxt +++ b/tensorflow/tools/api/golden/v1/tensorflow.pbtxt @@ -249,6 +249,10 @@ tf_module { mtype: "<type \'type\'>" } member { + name: "UnconnectedGradients" + mtype: "<class \'enum.EnumMeta\'>" + } + member { name: "VERSION" mtype: "<type \'str\'>" } @@ -1234,7 +1238,7 @@ tf_module { } member_method { name: "gradients" - argspec: "args=[\'ys\', \'xs\', \'grad_ys\', \'name\', \'colocate_gradients_with_ops\', \'gate_gradients\', \'aggregation_method\', \'stop_gradients\'], varargs=None, keywords=None, defaults=[\'None\', \'gradients\', \'False\', \'False\', \'None\', \'None\'], " + argspec: "args=[\'ys\', \'xs\', \'grad_ys\', \'name\', \'colocate_gradients_with_ops\', \'gate_gradients\', \'aggregation_method\', \'stop_gradients\', \'unconnected_gradients\'], varargs=None, keywords=None, defaults=[\'None\', \'gradients\', \'False\', \'False\', \'None\', \'None\', \'UnconnectedGradients.NONE\'], " } member_method { name: "greater" diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-unconnected-gradients.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-unconnected-gradients.pbtxt new file mode 100644 index 0000000000..c5eb959430 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-unconnected-gradients.pbtxt @@ -0,0 +1,12 @@ +path: "tensorflow.UnconnectedGradients" +tf_class { + is_instance: "<enum \'UnconnectedGradients\'>" + member { + name: "NONE" + mtype: "<enum \'UnconnectedGradients\'>" + } + member { + name: "ZERO" + mtype: "<enum \'UnconnectedGradients\'>" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.pbtxt index 5b3ea75bce..571abc3b19 100644 --- a/tensorflow/tools/api/golden/v2/tensorflow.pbtxt +++ b/tensorflow/tools/api/golden/v2/tensorflow.pbtxt @@ -221,6 +221,10 @@ tf_module { mtype: "<type \'type\'>" } member { + name: "UnconnectedGradients" + mtype: "<class \'enum.EnumMeta\'>" + } + member { name: "VERSION" mtype: "<type \'str\'>" } @@ -1134,7 +1138,7 @@ tf_module { } member_method { name: "gradients" - argspec: "args=[\'ys\', \'xs\', \'grad_ys\', \'name\', \'colocate_gradients_with_ops\', \'gate_gradients\', \'aggregation_method\', \'stop_gradients\'], varargs=None, keywords=None, defaults=[\'None\', \'gradients\', \'False\', \'False\', \'None\', \'None\'], " + argspec: "args=[\'ys\', \'xs\', \'grad_ys\', \'name\', \'colocate_gradients_with_ops\', \'gate_gradients\', \'aggregation_method\', \'stop_gradients\', \'unconnected_gradients\'], varargs=None, keywords=None, defaults=[\'None\', \'gradients\', \'False\', \'False\', \'None\', \'None\', \'UnconnectedGradients.NONE\'], " } member_method { name: "greater" |