ubuntu16.04的Anaconda下的tensorflow安裝py3.5


一、下載Anaconda,安裝。

sudo bash Ana...........sh

 

二、配置環境變量

 

 

加最后一句:/home/py/Ana/bin 就是安裝地址

 

安裝完畢reboot。

輸入python。看見Anaconda就對了

 

三、conda環境

創建一個PY3.5版本的名為tensorflow的環境

這里官網說用默認的源。其使用我下面推薦的那個比較快一點。。

 

 

conda install -n tensortflow -c https://conda.anaconda.org/jjhelmus tensorflow

 

IPython,高級Python運行環境

現已更名為Jupyter(http://jupyter.org/),支持通過notebook進行算法模型的共享。

Spark,高性能並行計算環境

從 https://conda.anaconda.org/anaconda-cluster 可以訪問到集成的Spark版本。

安裝:

conda install -n tensor -c https://conda.anaconda.org/anaconda-cluster spark

 

TensorFlow,機器學習引擎

TensorFlow是由Google開源的基於神經網絡的機器學習引擎,從 https://www.tensorflow.org/ 訪問詳細信息。

安裝:

conda install -n tensor -c https://conda.anaconda.org/jjhelmus tensorflow

四、測試
官網上的測試程序。對一個線性數據進行訓練的demo
import tensorflow as tf
import numpy as np

# Create 100 phony x, y data points in NumPy, y = x * 0.1 + 0.3
x_data = np.random.rand(100).astype(np.float32)
y_data = x_data * 0.1 + 0.3

# Try to find values for W and b that compute y_data = W * x_data + b
# (We know that W should be 0.1 and b 0.3, but TensorFlow will
# figure that out for us.)
W = tf.Variable(tf.random_uniform([1], -1.0, 1.0))
b = tf.Variable(tf.zeros([1]))
y = W * x_data + b

# Minimize the mean squared errors.
loss = tf.reduce_mean(tf.square(y - y_data))
optimizer = tf.train.GradientDescentOptimizer(0.5)
train = optimizer.minimize(loss)

# Before starting, initialize the variables.  We will 'run' this first.
init = tf.initialize_all_variables()

# Launch the graph.
sess = tf.Session()
sess.run(init)

# Fit the line.
for step in range(201):
    sess.run(train)
    if step % 20 == 0:
        print(step, sess.run(W), sess.run(b))

# Learns best fit is W: [0.1], b: [0.3]

這個就是是py3的直接可以跑

Ubuntu上推薦大家還是用sublime來寫代碼。

 

結果

 

 


免責聲明!

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



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