LoginSignup
8
10

More than 5 years have passed since last update.

Tensor Flowを初心者なりに導入してみた

Posted at

はじめに

Download and Setupを元に導入いたします。

  • OS X EX Capitan 10.11.5(15F34)
  • メモがてら書いているので、間違いがあるかもしれません。

インストール

pip

$ sudo easy_install pip
$ sudo easy_install --upgrade six

python3へ移行

以下の2つを参照させていただきました。

# OSのversionアップに伴う環境設定
$ xcode-select --install
xcode-select: note: install requested for command line developer tools


# python3.5.1のインストール
$ brew install pyenv
$ export PYENV_ROOT="$HOME/.pyenv"
$ export PATH="$PYENV_ROOT/bin:$PATH"
$ eval "$(pyenv init -)"
$ pyenv install 3.5.1


# 現状のpythonのバージョンを確認
$ pyenv versions
* system (set by /Users/harakenta/.pyenv/version)
  3.5.1

$ python --version
Python 2.7.10


# python3.5.1に切り替え
$ pyenv global 3.5.1
$ pyenv rehash

# 切り替えができているか確認
$ pyenv versions
  system
* 3.5.1 (set by /Users/harakenta/.pyenv/version)

$ python --version

TensorFlowのインストール

$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/tensorflow-0.9.0-py3-none-any.whl
$ sudo pip3 install --upgrade $TF_BINARY_URL

Test programで実行確認

TensorFlow:test the tensor flow installation
を実行してみて、実行できるか確認

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

demoModelの実行

#python->tensorflow参照先のチェック
$ python -c 'import os; import inspect; import tensorflow; print(os.path.dirname(inspect.getfile(tensorflow)))'
/Users/*****/.pyenv/versions/3.5.1/lib/python3.5/site-packages/tensorflow

#参照先直下に移動
$ cd /Users/*****/.pyenv/versions/3.5.1/lib/python3.5/site-packages/

#demoModelの実行
$ python -m tensorflow.models.image.mnist.convolutional
Successfully downloaded train-images-idx3-ubyte.gz 9912422 bytes.
Successfully downloaded train-labels-idx1-ubyte.gz 28881 bytes.
Successfully downloaded t10k-images-idx3-ubyte.gz 1648877 bytes.
Successfully downloaded t10k-labels-idx1-ubyte.gz 4542 bytes.
Extracting data/train-images-idx3-ubyte.gz
Extracting data/train-labels-idx1-ubyte.gz
Extracting data/t10k-images-idx3-ubyte.gz
Extracting data/t10k-labels-idx1-ubyte.gz
...学習しよる、しよる...

まとめ

とりあえず導入できたので、次はTutorialsをやりつつ、学習データを決定していきます!

迷走タイムメモ(個人反省メモ)

  1. r0.9試すとpython3.0が必要
  2. python3を導入がめんどくさいから0.6.0で試そうとする
  3. 元から入っているpython2のディレクトリが悪くInstallできない
  4. 仕方ないからpython3.0を導入するか。。。
  5. よくよく見るとr0.9もpython2対応してるやんw python2でとぅるっとやるか!
  6. version上がったからといって、ディレクトリの問題は解決してなかった。。。
  7. r0.9 x python3で頑張ってみる
  8. え、まさかの zipimport.ZipImportError: can't decompress data; zlib not available
  9. バージョン上げた弊害だったので、対応をしてpython3再インスコ
8
10
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
8
10