virtualEnv経由でのインストールです
$ sudo easy_install pip
$ sudo pip install --upgrade virtualenv
下記で、tensorflowディレクトリが作られる
`
virtualenv ~/tensorflow
下記でvirtualenvをActivateする。
$ cd ~/tensorflow
$ source bin/activate
$ pip install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.5.0-py2-none-any.whl
Collecting tensorflow==0.5.0 from https://storage.googleapis.com/tensorflow/mac/tensorflow-0.5.0-py2-none-any.whl
Using cached https://storage.googleapis.com/tensorflow/mac/tensorflow-0.5.0-py2-none-any.whl
Collecting numpy>=1.9.2 (from tensorflow==0.5.0)
Downloading numpy-1.11.3-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (4.2MB)
100% |████████████████████████████████| 4.2MB 263kB/s
Collecting six>=1.10.0 (from tensorflow==0.5.0)
Downloading six-1.10.0-py2.py3-none-any.whl
Installing collected packages: numpy, six, tensorflow
Successfully installed numpy-1.11.3 six-1.10.0 tensorflow-0.5.0
実行pathに移動
$ cd ~/tensorflow/tensorflow
sample.py
import tensorflow as tf
def x2_plus_b(x, b):
_x = tf.constant(x)
_b = tf.constant(b)
result = tf.square(_x)
result = tf.add(result, _b)
return result
with tf.Session() as sess:
result = sess.run([x2_plus_b(2., 3.)])
print result
動作確認
:tensorflow[master]$ python sample.py
can't determine number of CPU cores: assuming 4
I tensorflow/core/common_runtime/local_device.cc:25] Local device intra op parallelism threads: 4
can't determine number of CPU cores: assuming 4
I tensorflow/core/common_runtime/local_session.cc:45] Local session inter op parallelism threads: 4
[7.0]