Update custom_gradient.py

Added error raised when executing eagerly .

Fixes https://github.com/tensorflow/tensorflow/issues/29275
This commit is contained in:
Vishnuvardhan Janapati 2021-04-16 15:10:14 -07:00 committed by GitHub
parent 0bedfb5781
commit 6172fb6de0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -201,6 +201,10 @@ def custom_gradient(f=None):
Returns:
A function `h(x)` which returns the same value as `f(x)[0]` and whose
gradient (as calculated by `tf.gradients`) is determined by `f(x)[1]`.
Raises:
RuntimeError: tf.gradients is not supported when eager execution is
enabled. Use tf.GradientTape instead.
"""
if f is None: