TensorFlow tf.GradientTape() records operations for automatic differentiation.
Below are the code snippet for calculating gradient of loss function. This post uses some other
TensorFlow apis like tf.reduce_sum, tf.constant and tf.variable as well.

Below is the code snippet with TensorFlow 2.0, in this tf.GradientTap() is used for calculating gradients of loss with respect to weight and bias.

Category: TensorFlow