[[山内のサイト]]


**ノート/VRAE-y0astを試す 2017-05-05 [#w5e4bd1d]

-[[Variational Recurrent AutoEncoder:https://github.com/y0ast/Variational-Recurrent-Autoencoder]] が試したい。
-論文は [[Variational Recurrent AutoEncoder:http://arxiv.org/pdf/1412.6581.pdf]]  ICLR2015 workshop paper~
よく見ると、(このページでは閉じていなくて)
 This is the main model class file used for the [ICLR 2015 workshop paper](http://arxiv.org/pdf/1412.6581.pdf)
 
 For preprocessing the MIDI files into numpy ndarrays, we used code from the RNN-RBM model 
 by Boulanger-Lewandowski et al. found [here](http://deeplearning.net/tutorial/rnnrbm.html). 
 Direct download via [here](http://www.iro.umontreal.ca/~lisa/deep/midi.zip), 
 see specifically the util.py file.
 
 For some example code on how to use this class refer to [Variational-Autoencoder]
 (https://github.com/y0ast/Variational-Autoencoder), which uses largely the same structure.


-別に、[[Variational Recurrent Neural Networks:https://github.com/jych/nips2015_vrnn]] もある。~
いずれ。


-その他参考 [[Chainer-RAEを試す 2017-04-16>ノート/Chainer-VAEを試す 2017-04-16]]

** まず theano-VAE by y0ast のインストール・テストから [#yda8e478]

y0astのVAE

https://github.com/y0ast/Variational-Autoencoder

 This is an improved implementation of the paper 
 [Stochastic Gradient VB and the Variational Auto-Encoder]
 (http://arxiv.org/abs/1312.6114) by D. Kingma

***theanoでの「-fPIC を付けて再コンパイル」というエラー [#a4c6abb3]

Theanoのインストールはpip install theanoでよいのだが、実行しようとするとエラー:


 Problem occurred during compilation with the command line below:
 /usr/bin/g++ -shared -g -march=core-avx2 -mcx16 -msahf -mmovbe -mno-aes 
 -mpclmul -mpopcnt -mabm -mno-lwp -mfma -mno-fma4 -mno-xop -mbmi -mbmi2 
 -mno-tbm -mavx -mavx2 -msse4.2 -msse4.1 -mlzcnt -mno-rtm -mno-hle -mrdrnd 
 -mf16c -mfsgsbase -mno-rdseed -mno-prfchw -mno-adx -mfxsr -mxsave -mxsaveopt 
 -mno-pku --param l1-cache-size=32 --param l1-cache-line-size=64 
 --param l2-cache-size=46080 -mtune=generic 
 -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -m64 -fPIC 
 -I/home/yamanouc/.pyenv/versions/testchainer/lib/python3.5/site-packages/numpy/core/include 
 -I/home/yamanouc/.pyenv/versions/3.5.1/include/python3.5m 
 -I/home/yamanouc/.pyenv/versions/testchainer/lib/python3.5/site-packages/theano/gof -L/home/yamanouc/.pyenv/versions/3.5.1/lib 
 -fvisibility=hidden 
 -o /home/yamanouc/.theano/compiledir_Linux-3.10-el7.x86_64-x86_64-with-centos-7.3.1611-Core-x86_64-3.5.1-64/lazylinker_ext/lazylinker_ext.so 
 /home/yamanouc/.theano/compiledir_Linux-3.10-el7.x86_64-x86_64-with-centos-7.3.1611-Core-x86_64-3.5.1-64/lazylinker_ext/mod.cpp 
 -lpython3.5m
 /usr/bin/ld: 
 /home/yamanouc/.pyenv/versions/3.5.1/lib/libpython3.5m.a(abstract.o): 
 再配置 R_X86_64_32S (`_Py_NotImplementedStruct' に対する) は共有オブジェクト 
 作成時には使用できません。-fPIC を付けて再コンパイルしてください。
 /home/yamanouc/.pyenv/versions/3.5.1/lib/libpython3.5m.a: error adding symbols: 不正な値です
 collect2: エラー: ld はステータス 1 で終了しました

これに対して、[[TheanoをpyenvでインストールしたPython3.4.2で動かそうとしたら「PICオプションつけて再コンパイルしろよ」と怒られた時にやった対処メモ:http://qiita.com/sobeit@github/items/74ae8eb5bfc1c445016a]] を試してみる。

 env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.5.1
 pyenv: /home/yamanouc/.pyenv/versions/3.5.1 already exists
 continue with installation? (y/N) y
 Installing Python-3.5.1...
 Installed Python-3.5.1 to /home/yamanouc/.pyenv/versions/3.5.1

これでよかったみたい。

***その他、python 2⇒3 のトラブル(修正点) [#jd4369e3]
-まず、2to3で変更
-print文の変更  print foo ⇒ print(foo)
-cPickleの変更  3ではcPickleがpickleへ統合~
  import cPickle   ⇒   import pickle as cPickle
-pickleのコード問題
-- foo = pickle.load(f) ⇒ foo = pickle.load(f, encoding='latin-1')
-- pickle.dump(foo, open(foo, "w")) ⇒  pickle.dump(foo, open(foo, "wb"))
-dict.keys, dict.valuesの変更 2ではlistだが、3では<dict_keys>タイプ(イテレータ?)~
[[python2系とpython3系のdict.keys()の違い:http://qiita.com/rsakamot/items/828e6aae81b070b31b25]] 参照
  v2 〜 gradients = T.grad(logpx, self.params.values())
  v3 〜 gradients = T.grad(logpx, list(self.params.values()))

python run.pyの結果
 Loading MNIST data
 instantiating model
 iterating
 Epoch 1 finished. LB: -193.13942630004883, time: 22.93882179260254
 Epoch 2 finished. LB: -152.17926068115236, time: 22.983415603637695
 Epoch 3 finished. LB: -141.78999546813964, time: 25.816251039505005
 Epoch 4 finished. LB: -134.09676203918457, time: 35.48565602302551
 Epoch 5 finished. LB: -129.3757816772461, time: 33.819087982177734
 Epoch 6 finished. LB: -126.5218868560791, time: 33.814671993255615
 Epoch 7 finished. LB: -124.2016669769287, time: 33.75276041030884
 Epoch 8 finished. LB: -122.33388554382324, time: 29.438324451446533
 Epoch 9 finished. LB: -120.61246232604981, time: 32.500073194503784
 Epoch 10 finished. LB: -119.15768037414551, time: 32.28838777542114
 Epoch 11 finished. LB: -117.96833020019531, time: 32.12200999259949
 Epoch 12 finished. LB: -116.95969625854492, time: 33.01212692260742
 Epoch 13 finished. LB: -116.0748751373291, time: 33.174702644348145
 Epoch 14 finished. LB: -115.37304664611817, time: 33.529176235198975
 Epoch 15 finished. LB: -114.77945274353027, time: 33.358819007873535
 Epoch 16 finished. LB: -114.24921716308594, time: 33.41627240180969
 Epoch 17 finished. LB: -113.75724340820312, time: 33.510695934295654
 Epoch 18 finished. LB: -113.33487405395508, time: 27.549768209457397
 Epoch 19 finished. LB: -112.8858207397461, time: 26.95359206199646
 Epoch 20 finished. LB: -112.42874549865722, time: 27.91150999069214
 Epoch 21 finished. LB: -112.04825514221191, time: 29.66838049888611
 Epoch 22 finished. LB: -111.65374844360352, time: 31.67751693725586
 Epoch 23 finished. LB: -111.30206108093262, time: 26.115196466445923
 Epoch 24 finished. LB: -111.02172611999512, time: 27.03639793395996
 Epoch 25 finished. LB: -110.64638464355468, time: 26.693015336990356
 Epoch 26 finished. LB: -110.37738958740235, time: 29.896079540252686
 Epoch 27 finished. LB: -110.04933743286132, time: 28.93959379196167
 Epoch 28 finished. LB: -109.82248419189453, time: 26.84994149208069
 Epoch 29 finished. LB: -109.55030537414551, time: 30.656190395355225
 Epoch 30 finished. LB: -109.2820866394043, time: 32.65191030502319
 Epoch 31 finished. LB: -109.05390032958984, time: 31.8552508354187
 Epoch 32 finished. LB: -108.81380722045898, time: 31.82115077972412
 Epoch 33 finished. LB: -108.55094737243653, time: 30.668914556503296
 Epoch 34 finished. LB: -108.33887867736816, time: 33.27646565437317
 Epoch 35 finished. LB: -108.11496560668945, time: 32.647138595581055
 Epoch 36 finished. LB: -107.91885054016113, time: 32.020817279815674
 Epoch 37 finished. LB: -107.76293115234375, time: 32.566054821014404
 Epoch 38 finished. LB: -107.56913163757324, time: 33.20587468147278
 Epoch 39 finished. LB: -107.39383059692383, time: 33.59141778945923
 Epoch 40 finished. LB: -107.23872970581054, time: 33.2063512802124
 LB on validation set: -107.65726470947266


  
---------

メモ https://github.com/jych/nips2015_vrnn


トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS