Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What can be used to replace tf.train.GradientDescentOptimizer in TensorFlow 2

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.

like image 851
Dee Avatar asked Sep 26 '19 09:09

Dee


People also ask

Which of the following is minimized when you run TF train GradientDescentOptimizer () Minimize ()?

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.

What is train_ op in TensorFlow?

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)


1 Answers

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.

like image 149
Rishabh Sahrawat Avatar answered Oct 07 '22 00:10

Rishabh Sahrawat