Skip to content

Instantly share code, notes, and snippets.

@smison
Last active February 18, 2016 07:14
Show Gist options
  • Save smison/1bd5e6bb08dd0357fecf to your computer and use it in GitHub Desktop.
Save smison/1bd5e6bb08dd0357fecf to your computer and use it in GitHub Desktop.
TensorFlow lesson
TensorFlowの学習メモ
- TensorFlowをMac & Dockerで使ってみたよ
http://qiita.com/yanosen_jp/items/41938cc361c9e7c83acc#_reference-d6603d87a29be94ac9f4
- Setting up TensorFlow (Mac)
http://www.raydaq.com/getting-started-with-tensorflow-mac/
Docker is the easiest method to setup TensorFlow on a mac.
- TensorFlowで Hello Worldを動かしてみた&その解説
http://dev.classmethod.jp/machine-learning/tensorflow-hello-world/
- TensorFlowを算数で理解する
http://qiita.com/icoxfog417/items/fb5c24e35a849f8e2c5d
- TensorFlowでアニメゆるゆりの制作会社を識別する
http://kivantium.hateblo.jp/entry/2015/11/18/233834
- 【TensorFlowのTutorialをざっくり日本語訳していく】1. MNIST For ML Beginners
http://qiita.com/qooa/items/3719fec3cfe764674fb9
- TensorFlow Tutorial
https://www.tensorflow.org/versions/v0.6.0/tutorials/index.html
- AWSでサクッとChainerを使ってみる
http://orientalrobotics.blogspot.jp/2015/07/awschainer.html
- TensorFlow Tutorialの数学的背景
http://enakai00.hatenablog.com/entry/2016/02/16/222814
- TensorFlow導入
http://dev.classmethod.jp/machine-learning/tensorflow-hello-world/
$ sudo pip install virtualenv
$ mkdir ~/tensorflow
$ virtualenv --system-site-packages ~/tensorflow
$ cd ~/tensorflow
$ source bin/activate
(tensorflow) $ pip install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.5.0-py2-none-any.whl
- TensorFlowの仕組み
Tensor: 計算結果の値である多次元配列。edgeで表現される
ops: Tensorデータを受け取り、計算処理をしたあとで、次のopsノードに結果を渡す。nodeで表現される。
addとかsquareとかが該当。
Session: opsに計算資源を割り当てるコンポーネント。Tensort + opsからなるグラフを受け取りdevices(cpu, gpu)に割り当てるイメージ。
sessionをrun()するまで計算結果は確定しない。計算可能になったopsから処理していく。
tf.constant(): Tensor型データを生成
- tensorboards
(tensorflow) $ tensorboard --logdir=<ログのフルパス>
localhost:6006にserveされて計算結果のグラフが見られる
ログはtf.train.SummaryWriter()でsessionに書き出させることができる
- Chainer導入
http://chainer.org/
$ sudo easy_install pip
$ sudo pip install chainer
* 上記だと上手く入らなかったが、下記のようにtensorflow環境だと入った
(tensorflow) $ sudo pip install chainer
- tensorflow | tensorboard用log出力例(xを動かした時のグラフが、b=0,1,2の場合において出力される)
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
def monitor_calculation(x, b):
title = "b = {0}".format(b)
c = x2_plus_b(float(x), float(b))
s = tf.scalar_summary(title, c)
m = tf.merge_summary([s]) # if you are using some summaries, merge them
return m
with tf.Session() as sess:
writer = tf.train.SummaryWriter("log", graph_def=sess.graph_def)
xaxis = range(-10, 12)
for b in range(3):
for x in xaxis:
summary_str = sess.run(monitor_calculation(x, b))
writer.add_summary(summary_str, x)
- 一般物体認識
LabbelioとかCaffe使うのが楽そう
- Caffeの使用例
- 友利奈緒判定botを作った
http://kivantium.hateblo.jp/entry/2015/09/04/123128
- Trouble shoot
- 『$ python hoge.py』で『got an unexpected keyword argument 'syntax'』
参考: http://qiita.com/light14/items/31ee6ff5f7823bab917f
$ pip uninstall protobuf
$ pip uninstall tensorflow
$ pip install https://storage.googleapis.com/tensorflow/mac/tensorflow-0.5.0-py2-none-any.whl
$ python hoge.py #=> OK
- TensorFlow Tutorials
- https://www.tensorflow.org/versions/r0.7/tutorials/mnist/beginners/index.html
- 参考: http://qiita.com/shuhei_f/items/9251084b00ed9319033e
1. これをimport用にそのままの名前でコピペ https://github.com/tensorflow/tensorflow/blob/r0.7/tensorflow/examples/tutorials/mnist/input_data.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment