x = tf.constant(3.0)
with tf.GradientTape() as g:
g.watch(x)
with tf.GradientTape() as gg:
gg.watch(x)
y = x * x
dy_dx = gg.gradient(y, x) # Will compute to 6.0
d2y_dx2 = g.gradient(dy_dx, x) # Will compute to 2.0
in TensorFlowCAPITest>>#testNestedGradient but the got the following error
It seems gradientsOf:respectTo: in VAST is not doing the same as the gradient in python.
gradientsOf:respectTo: ends up calling the C++ api TF_AddGradients
while gradient in python calls tensorflow.python.eager.imperative_grad.imperative_grad, which calls tensorflow.python.pywrap_tensorflow.TFE_Py_TapeGradient, which is a C++ function calling ComputeGradient.
I intend to write the second example in the GradientTape tutorial
in
TensorFlowCAPITest>>#testNestedGradient
but the got the following errorIt seems
gradientsOf:respectTo:
in VAST is not doing the same as thegradient
in python.gradientsOf:respectTo:
ends up calling the C++ api TF_AddGradientsgradient
in python calls tensorflow.python.eager.imperative_grad.imperative_grad, which calls tensorflow.python.pywrap_tensorflow.TFE_Py_TapeGradient, which is a C++ function calling ComputeGradient.(Case reproduced in this commit)