diff options
author | 2018-09-01 05:48:14 -0700 | |
---|---|---|
committer | 2018-09-01 05:51:59 -0700 | |
commit | 543bc6a8b98e8d08ce9c25dcafe629e124f266eb (patch) | |
tree | 31071254618c914eadc814253ad6edef8b68da92 /tensorflow/python/pywrap_tfe.i | |
parent | dcbd97c2939ddbfadf9e21f1c0e6aa720b9154d6 (diff) |
Only watch tensors on the current tape rather than all of them.
This allows fine grained control over recording in some cases, for example the
following where we want d2y but not d2z:
x1 = tf.Variable(2.0, trainable=False)
x2 = tf.Variable(2.0, trainable=False)
with tf.GradientTape() as tape1:
with tf.GradientTape() as tape2:
tape1.watch(x1)
tape2.watch([x1, x2])
y = x1 ** 3
z = x2 ** 2
dy, dz = tape2.gradient([y, z], [x1, x2])
d2y, d2z = tape1.gradient([dy, dz], [x1, x2])
assert d2z is None
PiperOrigin-RevId: 211206506
Diffstat (limited to 'tensorflow/python/pywrap_tfe.i')
-rwxr-xr-x | tensorflow/python/pywrap_tfe.i | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tensorflow/python/pywrap_tfe.i b/tensorflow/python/pywrap_tfe.i index e1c233cdd9..a31861ae40 100755 --- a/tensorflow/python/pywrap_tfe.i +++ b/tensorflow/python/pywrap_tfe.i @@ -50,11 +50,11 @@ limitations under the License. %rename("%s") TFE_Py_TapeSetRestartOnThread; %rename("%s") TFE_Py_TapeSetIsEmpty; %rename("%s") TFE_Py_TapeSetShouldRecord; -%rename("%s") TFE_Py_TapeSetWatch; %rename("%s") TFE_Py_TapeSetDeleteTrace; %rename("%s") TFE_Py_TapeSetRecordOperation; %rename("%s") TFE_Py_TapeSetWatchVariable; %rename("%s") TFE_Py_TapeGradient; +%rename("%s") TFE_Py_TapeWatch; %rename("%s") TFE_Py_TapeWatchedVariables; %rename("%s") TFE_NewContextOptions; %rename("%s") TFE_ContextOptionsSetConfig; |