TensorFlow中报错 module 'tensorflow_core._api.v2.train' has no attribute 'GradientDescentOptimize

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/xiewenrui1996/article/details/102522887

原来函数是这样写的:

optimizer = tf.train.GradientDescentOptimizer

报错: AttributeError: module 'tensorflow_core._api.v2.train' has no attribute 'GradientDescentOptimizer'

此时应改为:

optimizer = tf.compat.v1.train.GradientDescentOptimizer

就可以啦

猜你喜欢

转载自blog.csdn.net/xiewenrui1996/article/details/102522887
今日推荐