ValueError: ('`tf.compat.v1.keras` Optimizer is not supported when eager execution is enabled. Use a `tf.keras` Optimizer instead, or disable eager execution.')

ValueError: ('`tf.compat.v1.keras` Optimizer (', <tensorflow.python.keras.optimizers.SGD >, ') is not supported when eager execution is enabled. Use a `tf.keras` Optimizer instead, or disable eager execution.')

ValueError: ('`tf.compat.v1.keras` Optimizer (', <tensorflow.python.keras.optimizers.SGD object at 0x7ff814173dc0>, ') is not supported when eager execution is enabled. Use a `tf.keras` Optimizer instead, or disable eager execution.')

 

 

Solution -

Modify,

from tensorflow.python.keras.optimizers import Adam

to

from tensorflow.keras.optimizers import Adam

Note : Also kindly import other libraries from tensorflow.keras instead of tensorflow.python.keras.

 

posted @ 2023-10-09 22:31  emanlee  阅读(149)  评论(0编辑  收藏  举报