解決問題module 'tensorflow.compat.v2' has no attribute 'contrib'和ImportError cannot import name 'auto'

Error:

當前tensorflow的版本是1.13.1和2.0.0b1報錯module 'tensorflow.compat.v2' has no attribute 'contrib',

嘗試用import tensorflow.compat.v1 as tf 代替import tensorflow as tf,

但仍有問題 ImportError cannot import name 'auto'

 

Solution:

如下圖所示,參考文章1中指出tf2.0 alpha開始移除了tf.contrib,需要升級。

因此使用命令pip install --upgrade tensorflow 升級爲tensorflow 2.1.0即可。

 

 

 

 

 

參考文章:

1. https://stackoverflow.com/questions/55870127/module-tensorflow-has-no-attribute-contrib

 

發佈了32 篇原創文章 · 獲贊 26 · 訪問量 6萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章