Hello everyone !) I am trying to understand how works 2x gradient call at the same GradientTape -
x = tf.constant(3.0)
with tf.GradientTape(persistent=True) as g:
g.watch(x)
y = x * x
z = y * y
dz_dx = g.gradient(z, x) # (4*x^3 at x = 3)
print(dz_dx)
>> tf.Tensor(108.0, shape=(), dtype=float32)
dy_dx = g.gradient(y, x)
print(dy_dx)
>>
tf.Tensor(6.0, shape=(), dtype=float32)
first, we get ‘2x’ derivative from y = x * x, then we get ‘4x^3’ derivative from z = y * y…
So i can`t understand how obtained '4x^3’ ). Thanks !