1、安裝時注意版本兼容問題!!!!
tensorflow、keras、python版本兼容問題
https://docs.floydhub.com/guides/environments/

2、查看版本時
version前后是兩條橫線(天坑)
區別:
tf._ version _
tf.__ version __
3、代碼show_train_history(train_history, ‘accuracy’, ‘val_accuracy’)
由于版本問題,acc,val_acc是不對的,補全即可
4、AttributeError: module ‘tensorflow’ has no attribute 'Session’錯誤解決
因為在新的Tensorflow 2.0版本中已經移除了Session這一模塊,改換運行代碼
tf.compat.v1.Session()
init = tf.compat.v1.global_variables_initializer()
5、RuntimeError: The Session graph is empty. Add operations to the graph before calling run().解決方法
問題產生的原因:無法執行sess.run()的原因是tensorflow版本不同導致的,tensorflow版本2.0無法兼容版本1.0.
解決辦法:加上一行代碼
tf.compat.v1.disable_eager_execution()
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/287866.html
標籤:AI
