Anaconda3(python3.6)安裝tensorflow
Anaconda3中安裝tensorflow3是非常簡單的,僅需通過
pip install tensorflow
測試代碼:
import tensorflow as tf
>>> hello =tf.constant("Hello TensorFlow~") >>> soss=tf.Session() >>> print(soss.run(hello)) b'Hello TensorFlow~' >>> a=tf.constant(10) >>> b=tf.constant(32) >>> print(soss.run(a+b)) #輸出42
下面文章是之前在Anaconda3中配置Tensorflow庫的過程
Anaconda3(python3.5)配置TensorFlow深度學習庫
前言:目前Google已經發布了TensorFlow的Windows版本,只支持64位Python3.5,我們使用Anaconda3配置使用。
1.下載Anaconda3並打開Anaconda Navigator
URL:https://www.continuum.io/downloads
2.新建TensorFlow環境
3.打開TensorFlow終端
並輸入以下命令
pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-0.12.1-cp35-cp35m-win_amd64.whl
在PC聯網的情況下下載依賴包,如下圖最后會出現成功提示
4. 安裝成功環境測試
測試代碼如下:(官網給的是單引號,需要改為雙引號)
python -c "import os; import inspect; import tensorflow; print(os.path.dirname(inspect.getfile(tensorflow)))"
顯示如下:
5.案例測試
輸入Python在3.5.2的環境下做測試
測試代碼示例:
import tensorflow as tf >>> hello =tf.constant("Hello TensorFlow~") >>> soss=tf.Session() >>> print(soss.run(hello)) b'Hello TensorFlow~' >>> a=tf.constant(10) >>> b=tf.constant(32) >>> print(soss.run(a+b)) #輸出42