Gradient of function f is collection of all partial derivatives into a vector.
In machine learning, computing gradient is necessary to train neural network. Taking need into consideration Tensorflow provides the GradientTape() Api for computing gradients. It compute the gradient with respect to variable.
Here is an example,
import tensorflow as tf
x = tf.Varible(2.3)
with tf.GradientTape() as tape:
y = x ** 2 + x
grad = tape.gradient(y, x)
print(grad.numpy())
5.6