tensorflow 使用

1.linux 安装tensorflow

ubuntu中安装:link

用pip安装的过程中,可能出现网络链接的问题,尝试多次链接,直到成功!!!

python -V

sudo apt-get install python-pip python-dev

problem:关于python升级,和pip正常使用。细节:请看python升级。

demo:

$ python

>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> sess.run(hello)
Hello, TensorFlow!
>>> a = tf.constant(10)
>>> b = tf.constant(32)
>>> sess.run(a+b)
42
>>>
$ vim tensorboard_test.py

tensorboard_test.py

import tensorflow as tf
import numpy as np

WW = np.array([[0.1, 0.6, -0.9], 
               [0.2, 0.5, -0.8], 
               [0.3, 0.4, -0.7],
               [0.4, 0.3, -0.6],
               [0.5, 0.2, -0.5]]).astype(np.float32)
bb = np.array([0.3, 0.4, 0.5]).astype(np.float32)
x_data = np.random.rand(100,5).astype(np.float32)
y_data = np.dot(x_data, WW) + bb

with tf.Session() as sess:

    W = tf.Variable(tf.random_uniform([5,3], -1.0, 1.0))
    # The zeros set to zero with all elements.
    b = tf.Variable

$ python  tensorboard_test.py

 

posted @ 2016-10-02 21:10  encourage  阅读(188)  评论(0编辑  收藏  举报