I am trying to calculate partial derivative for the below function, could you advise if this is the right way to calculate partial derivative using TensorFlow?
f(x,y,z) = xy+z pow 2 + 1/x
x = tf.Variable(2, name='x')
y = tf.Variable(1, name='y')
z = tf.constant(4, name='z')
with tf.GradientTape(persistent=True) as t:
t.watch(x)
f = x*y + tf.pow(z,2) + tf.divide(1,x)
g = tape.gradient(f, [x,y,z])
print(g)