DOsinga / deep_learning_cookbook

Deep Learning Cookbox
Apache License 2.0
686 stars 335 forks source link

14.3 Icon GAN--AttributeError: module 'tensorflow_core._api.v2.train' has no attribute 'AdamOptimizer' #78

Open mikechen66 opened 4 years ago

mikechen66 commented 4 years ago

Hi Douwe:

While running the script on TensorFlow 2.0 and Keras 2.3.1, it shows the AttributeError. After changing the adam method from tf.train.AdamOptimizer() to tf.optimizers.Adam(), it shows the TensorFlow methods including compute_gradient(), get_session() method need to be changed accordingly. It is a chained response and hard to be fixed. I think that the solution depends on you.

AttributeError

generating GAN...


AttributeError Traceback (most recent call last)

in 65 66 print('generating GAN...') ---> 67 gan_feed = gan(generator, discriminator) in gan(g, d) 19 gloss = - K.mean(log_eps(gscore)) 20 ---> 21 Adam = tf.train.AdamOptimizer 22 23 lr, b1 = 1e-4, .2 # otherwise won't converge. AttributeError: module 'tensorflow_core._api.v2.train' has no attribute 'AdamOptimizer'