天天看點

AttributeError: module ‘tensorflow‘ has no attribute ‘app‘

看了一些部落客的方法,我采用的方法是:

(1)把tensorflow先更新: pip install --upgrade tensorflow-cpu

(發現其實我的版本已經是最高的了)

AttributeError: module ‘tensorflow‘ has no attribute ‘app‘

(2)将import tensorflow as tf 改為 import tensorflow.compat.v1 as tf

由于tensorflow版本的原因,我的tensorflow的版本是2.5.0的,而源代碼是tensorflow1.幾版本的,是以隻需要将源檔案裡面的

import tensorflow as tf

改為 import tensorflow.compat.v1 as tf

AttributeError: module ‘tensorflow‘ has no attribute ‘app‘

參考連結: https://blog.csdn.net/weixin_41012399/article/details/103654641.

繼續閱讀