Theanoのshared変数についてメモ
shared変数(共有変数)の使いどころとscanのloop型構文との使いわけが分からなかったのでメモ
こちらの最小二乗法の説明が分かりやすかった。
http://qiita.com/mokemokechicken/items/3fbf6af714c1f66f99e9
logictic regressionの例
http://deeplearning.net/software/theano/tutorial/examples.html#a-real-example-logistic-regression
theano.functionのupdates引数に共有変数の更新式を代入する。
c.get_value()で共有変数の値を取り出す。
1stepごとに値が変わることからverilogのreg変数が共有変数、wire変数がtensorに相当するのではないかと思った。
scanのloop型構文ではこれをn_steps回だけ一気に実行する関数を生成する。
http://sinhrks.hatenablog.com/entry/2015/04/25/233025
微分方程式を逐次的に解く例
http://nbviewer.ipython.org/gist/xiangze/d34359197e5f0b19fd44
for文と比べてscanを使ったほうが圧倒的に速い。この場合scanでは共有変数を使っていない。
乱数は毎回値が変わらなければいけないので共有変数(当然)。
theano.tensor.shared_randomstreams
theano.tensor.nnet.neighboursを使うと偏微分方程式が書けて解けるはず。
http://deeplearning.net/software/theano/library/tensor/nnet/neighbours.html