Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cc5c86c

Browse files
authored
Add instructions for adding gradients (tensorflow#241)
* Add instructions for adding gradients * Add example PR links
1 parent 2e8f00c commit cc5c86c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

CONTRIBUTING.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,14 @@ bazel-out/k8-opt/bin/external/org_tensorflow/tensorflow/libtensorflow_cc.so --ou
112112
```
113113

114114
(called in `tensorflow-core-api`).
115+
116+
## Adding Gradients
117+
118+
In some cases, a op supported by Tensorflow Java will not have a gradient defined, resulting in errors like this:
119+
```
120+
org.tensorflow.exceptions.TensorFlowException: No gradient defined for op: ReadVariableOp. Please see https://www.tensorflow.org/code/tensorflow/cc/gradients/README.md for instructions on how to add C++ gradients.
121+
at org.tensorflow.internal.c_api.AbstractTF_Status.throwExceptionIfNotOK(AbstractTF_Status.java:101)
122+
at org.tensorflow.Graph.addGradients(Graph.java:708)
123+
at org.tensorflow.Graph.addGradients(Graph.java:291)
124+
```
125+
The description in the [linked file](https://www.tensorflow.org/code/tensorflow/cc/gradients/README.md) are accurate for adding C++ Graph gradients, which are used by our `Graph`. Eexamples of doing that are [tensorflow/tensorflow#46115](https://github.com/tensorflow/tensorflow/pull/46115) and [tensorflow/tensorflow#47774](https://github.com/tensorflow/tensorflow/pull/47774). However, Tensorflow Core is in the process of migrating gradient definitions to [`c/experimental/gradients`](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/c/experimental/gradients), which will be what our eager mode uses once it has gradient support. Anyone adding gradients is strongly encouraged to add one there as well, and eventually it should replace the legacy `cc/gradients` gradients.

0 commit comments

Comments
 (0)