現在機器學習廣泛應用下套件改版速度也是非常快速,於是許多同學會在安裝套件上踩到非常多坑,其中包含了Python版本對應的不同、code編寫 import 問題以及Tensorflow 套件缺少等相關,以下將針對上述這些問題進行統整。
Python對應Tensorflow安裝版本:
首先前往Tensorflow官方網站 : https://www.tensorflow.org/?hl=zh-tw
透過上方導覽列點安裝進入頁面

可透過頁面查到相關版本對應,包含CPU或GPU支援資訊

使用Tensorflow2.0以上版本使用Session() 時出現AttributeError: module 'tensorflow' has no attribute 'Session'該如何解決:
以上是基於Session()方法是1.0版本對應套件方法,如果需要使用到此方法需要在進行import時使用import tensorflow.compat.v1 as tf 後再添加tf.disable_v2_behavior()

Tensorflow套件source該如何找,以Examples為例?
可以到Tensorflow的GitHub,https://github.com/tensorflow/tensorflow
方法一:將整個Tensorflow資料下載後解壓縮

以下是解壓Github載下的Tensorflow完整資料包中examples示意圖

再複製到Python安裝目錄的套件庫中

備註:在Python主程式下的Lib/site-packages目錄中
方法二:將Github頁面往下拉到 Resources 項目並找到 TensorFlow Examples

將整包Examples下載

同樣放入site-packages/tensorflow 目錄下即可生效

以上理解後, 就能應用在任何Tensorflow的source上囉~~~
Comments