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