13
26

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Mac + Python + Anaconda を利用してTensorFlowを動かしてみる

13
Posted at

動作環境

  • Mac OSX
  • pyenv
  • anaconda3-5.0.0(Python 3.6)

環境構築は以下のサイト参照

Mac + Python + Anaconda を使用した機械学習用の環境構築

TensorFlow インストール

$ mkdir tensorflow-test
$ virtualenv --system-site-packages tensorflow-test
$ cd tensorflow-test
$ source bin/activate
$ conda search tensorflow

Fetching package metadata ...........
r-tensorflow                 0.8.2                  r3.4.1_0  defaults
                             1.4              r342h38ebd79_0  defaults
tensorflow                   1.1.0               np112py27_0  defaults
                             1.1.0               np112py35_0  defaults
                             1.1.0               np112py36_0  defaults

$ conda install tensorflow

$ pip list | grep tensor

tensorflow (1.1.0)

インストールが確認できればOKです!

Tensorflowを実行してみる

以下のファイルをローカルに作成します。(後ほどjupyterに貼り付けるコードです)

hello_world.py

import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))

a = tf.constant(100)
b = tf.constant(321)
print(sess.run(a + b))

Jupyter を使用して動作確認

$ jupyter notebook

コマンドを実行するとブラウザが立ち上がり、以下のような画面が表示されます。

スクリーンショット 2017-11-25 15.17.43.png

画面右側にある「New」をクリックし、「Python3」をクリックしてください。

入力画面が表示されるので hello_world.py で入力したソースをコピペし、shift + enter でソースコードを実行してください。

スクリーンショット 2017-11-25 15.26.27.png

これでTensorFlowの動作確認は終わりです!
次回はこの環境を使用してTensorFlowのチュートリアルを行います。

13
26
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
26

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?