在Win10 Anaconda中安裝Tensorflow


有需要的朋友可以參考一下

1、安裝Anaconda

 下載:https://www.continuum.io/downloads,我用的是Python 3.5 

下載完以后,安裝。
 
安裝完以后,打開Anaconda Prompt,輸入清華的倉庫鏡像,更新包更快:

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes

推薦第一行命令輸入兩次,以便把這個鏡像地址放在首位。

2、安裝TensorFlow

繼續打開Anaconda Prompt,輸入:
conda create -n tensorflow python=3.5

安裝完以后,輸入:
activate tensorflow

激活后,我選擇安裝的是CPU版本,輸入:
 
安裝失敗的話多試幾次

3、測試:

 
 1 # 進入一個交互式 TensorFlow 會話.
 2 import tensorflow as tf
 3 sess = tf.InteractiveSession()
 4 
 5 x = tf.Variable([1.0, 2.0])
 6 a = tf.constant([3.0, 3.0])
 7 
 8 # 使用初始化器 initializer op 的 run() 方法初始化 'x' 
 9 x.initializer.run()
10 
11 # 增加一個減法 sub op, 從 'x' 減去 'a'. 運行減法 op, 輸出結果 
12 sub = tf.sub(x, a)
13  sub.eval()
14 # ==> [-2. -1.]

 

4、關閉

當你不用 TensorFlow 的時候,關閉環境:

  deactivate
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM