首页 > 解决方案 > TensorFlow 2 中可以用什么代替 tf.train.GradientDescentOptimizer

问题描述

tf.train.GradientDescentOptimizer我正在尝试将我的 TensorFlow 1.4 代码转换为 TensorFlow 2,但TF 2 中没有更多代码。

tf.train.GradientDescentOptimizer 的替代品应该是什么?

我发现了同样的东西,tf.compat.v1.train.但我不应该使用它,因为这些东西tf.compat迟早会被删除。

标签: pythontensorflowkerasversionoptimizer-statistics

解决方案


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.


推荐阅读