解决module ‘tensorflow‘ has no attribute ‘optimizers‘报错
生活随笔
收集整理的這篇文章主要介紹了
解决module ‘tensorflow‘ has no attribute ‘optimizers‘报错
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
一般出現此類問題的原因是包的更新導致有些用法發生了變化,因此在tensorflow中調用optimizer需要通過tf.keras調用。
將self.opt = tf.optimizers.Adam(learning_rate=self.lr)中的tf后面加個keras,
變成self.opt = tf.keras.optimizers.Adam(learning_rate=self.lr)
總結
以上是生活随笔為你收集整理的解决module ‘tensorflow‘ has no attribute ‘optimizers‘报错的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 解决import tensorflow时
- 下一篇: 红魔9 Pro挑战器件堆叠极限:首款不凸