0

I have seen several example using GradientDescentOptimizer. Here is a good one

Tensorflow GradientDescentOptimizer example

The model in the above example is :

y_model = tf.multiply(x, w[0]) + w[1]

Do we provide tensorflow the gradient function? How does it know how to calculate the gradient?

CrazyBrazilian
  • 1,030
  • 1
  • 11
  • 15

1 Answers1

0

No, we do not provide gradient function. This is the beauty of automatic differentiation that TF and many other DL frameworks use.

Knowing the function that you need to optimize, the differentiator uses the rules for taking the derivative of each element of a program (when you define any op in core TF, you need to register a gradient for this op). It also uses chain rule to break complex expressions into simpler ones.

For more information check these answers:

Salvador Dali
  • 214,103
  • 147
  • 703
  • 753