I'm trying to convert my TensorFlow 1.4 code to TensorFlow 2 but in there's no more tf.train.GradientDescentOptimizer
in TF 2.
What should be the replacement for tf.train.GradientDescentOptimizer?
I found the same thing in tf.compat.v1.train.
but I shouldn't use it as those stuff in tf.compat
will be removed sooner or later.
GradientDescentOptimizer(0.01). minimize(error) where the training step is defined. It aims to minimise the value of the error Variable, which is defined earlier as the square of the differences (a common error function). The 0.01 is the step it takes to try learn a better value.
This is, by convention, known as the train_op and is what must be run by a TensorFlow session in order to induce one full step of training (see below). global_step = tf. Variable(0, name='global_step', trainable=False) train_op = optimizer. minimize(loss, global_step=global_step)
You can replace it with, tf.keras.optimizers.SGD()
defined here.
Here (skip to third point) is the official message, where TF team mentioned to use this keras optimizer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With