配置python與tensorflow,keras出現問題

  • 1.對於python3.7與python3.6會出現好多不同,模塊位置發生變化,出現錯誤要百度,不能夠直接找
    初學者使用MNIST庫來練習。一些老代碼就會提示找不到:
    ImportError: No module named ‘input_data’
    其實就是模塊位置發生了變化。把代碼換成下面就好
    #import input_data
    from tensorflow.examples.tutorials.mnist import input_data
    mnist = input_data.read_data_sets("/tmp/data/", one_hot=True)

  • 2.ERROR: astroid 2.2.5 requires typed-ast>=1.3.0; implementation_name == “cpython”
    , which is not installed.
    對於tensorflow進行升級
    pip install --upgrade tensorflow-gpu,
    初學者不建議升級,直接忽略不使用,後期使用出現較大問題

  • 3.tensorlayer模塊,使用必須tensorflow爲2.0.0,但是在升級之後很多函數名會與以前不同,初學者超級麻煩,建議不使用tensorlayer類似的學習文檔,因爲目前tensorflow2.0.0的學習資料太少。
    不同對照表格

  • 4.AttributeError: module ‘tensorflow’ has no attribute ‘get_default_graph’
    這是因爲keras與tensorflow2.0.0的兼容性出現問題,參考keras和tensorflow-2.0.0-beta1的兼容性問題 - yxdayd的專欄 - CSDN博客

  • 5.Compressed file ended before the end-of-stream marker was reached
    壓縮文件在到達結束後結束
    python在下載時,出現上述錯誤提示,一般這種問題都是因爲所下載文件已經存在或下載了部分。若再重新下載,這會出現上述錯誤。
    解決方式:找到下載的文件目錄刪除。

  • 6使用keras 運行時報 cannot import name ‘tf_utils’
    keras默認版本高,安裝 pip3 install keras==2.2.0 解決

  • 7每次運行tensorflow出現警告FutureWarning: Passing (type, 1) or ‘1type’ as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / ‘(1,)type’.
    np_resource = np.dtype([(“resource”, np.ubyte, 1)])
    解決python調用TensorFlow時出現FutureWarning- Passing (type, 1) or ‘1type’ as a synonym of type is deprecate - BigDream123的博客 - CSDN博客

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章