しゃけぶろ

日本語教師。タイ・台湾・沖縄あたりを外こもり。国内外ライブレポ。チラ裏的ログ。

人工生命サンプル実行成功。


Artificial life(ALife) sample test success 人工生命サンプルテスト成功。

 

ニコニコ超会議で超人工生命のブースでLIS開発者の中村くんの発表聞いてておもしろそうだったので

Unity, Python, ChainerLISをインストールしてみた。

僕の環境は、Mac OS 10.11(El capitan),Python2.7.11

https://github.com/wbap/lis

人工生命自体は、カプセル型だったりだったりしてたので、

萌えキャラにすればとりあえず良いんじゃないかと思い挑戦。

 

Chainer入れるとこでだいぶハマったりしてたが、ググッて解決した。

 

次の

http://d.hatena.ne.jp/shi3z/20160406/1459950099

pip install -r requirements.txt

でエラー。

File "/private/var/folders/1p/h8bxtr0s3g30wj5sd7n2jq9r0000gn/T/pip-build-F0jchc/pillow/setup.py", line 512, in build_extensions

        ' using --disable-%s, aborting' % (f, f))

ValueError: jpeg is required unless explicitly disabled using --disable-jpeg, aborting

 

 

解決策

brew install libjpeg libjpeg-turbo libpng

 

不意なところで、環境が整ってなかったりしてエラーになるw libpngは別に今回は不要だと思うが、どうせなんで。

 

 

————

lis.pyを起動して、Unityでサンプルを開き実行ボタンを押すと

File “~ deel/agentServer.py", line 62, in received_message

    screen = Image.open(io.BytesIO(bytearray(dat['image'])))

TypeError: an integer or string of size 1 is required

なるエラーがターミナルにでた。

 

———

$python cnndqn.py

を実行したときもエラーとなった。

 

Loading bvlc_alexnet.caffemodel

Traceback (most recent call last):

  File "cnndqn.py", line 10, in <module>

    QNET = DQN(CNN.layerDim(u'pool5'),actions=[0,1,2,3])

NameError: name 'DQN' is not defined

——

$python test.py

 

No module named cv2

なるエラー。OpenCVが入ってないようだ。

http://qiita.com/ru_pe129/items/f065f79b1322a82edb1d

 

$python

Python 2.7.11 (default, May  8 2016, 16:26:30)

[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin

Type "help", "copyright", "credits" or "license" for more information.

>>> import cv

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

ImportError: No module named cv

>>> import cv2

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

ImportError: No module named cv2

 

これで解決

http://ser1zw.hatenablog.com/entry/2012/10/28/085233

http://mollifier.hatenablog.com/entry/2013/02/22/025415

 

dist-packages site-packagesだが。

私の場合のVer.ではこんなのを.zshrcに追記した。

PYTHONPATH=/usr/local/Cellar/opencv/2.4.12_2/lib/python2.7/site-packages:$PYTHONPATH

これで、$python test.py

% python test.py                                                 (git)-[master]

Loading bvlc_googlenet.caffemodel

Converting from bvlc_googlenet.caffemodel

#1 | hook, | 860.6%

#2 | face | 794.9%

#3 | buckle | 784.4%

#4 | digital | 716.4%

#5 | loupe, | 715.7%

 

とエラーでずに成功した

———

%python lis.py 

とやって、UnitySampleを開き実行ボタン押すと、また下記のエラー。

 

Python/deel/deel/agentServer.py", line 62, in received_message

    screen = Image.open(io.BytesIO(bytearray(dat['image'])))

TypeError: an integer or string of size 1 is required

 

今一度

https://github.com/wbap/lis

を確認。

QuickStartの処理をしてみる。

fetch.shの中身をみてみると、caffemodelDLするようだ。

まだやってなかった!いろいろ流れがわからん。

 

caffemodelDLして、

python server.py

をしたらできた!

人工生命が動いたぞぉおおおおお!!!

(caffemodelを読み込むのに3分ぐらい時間かかってた)

 

——

しかし、一難去ってまた一難。

学習のログを見ようと

% python plot_reward_log.py                                      (git)-[master]

Traceback (most recent call last):

  File "plot_reward_log.py", line 1, in <module>

    import matplotlib.pyplot as plt

ImportError: No module named matplotlib.pyplot

 

このエラー。

 

sudo pip uninstall matplotlib

で解決

——

% python plot_reward_log.py 

 

ImportError: dlopen(/Users/~/matplotlib/_path.so, 2): Symbol not found:

matplotlib/_path.so

  Expected in: flat namespace

 

http://ameblo.jp/oyasai10/entry-12140949453.html

で解決したとおもいきやmatplotlibをインストール成功させてからもう一度

 

% python plot_reward_log.py 

をやると

 

RuntimeError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework. See the Python documentation for more information on installing Python as a framework on Mac OS X. Please either reinstall Python as a framework, or try one of the other backends. If you are Working with Matplotlib in a virtual enviroment see 'Working with Matplotlib in Virtual environments' in the Matplotlib FAQ

 

http://qiita.com/katryo/items/918667f28301fdec89ba

で解決

————

% python plot_reward_log.py                                      (git)-[master]

Traceback (most recent call last):

  File "plot_reward_log.py", line 2, in <module>

    import pandas as pd

ImportError: No module named pandas

 

% pip install pandas 

で解決

———

40000回学習させた結果表示できた~( ᴖ‿ᴖ )

縦軸は、キューブを食べた回数。

 

https://www.instagram.com/p/BFMEJuOK_k2JdWjqaEFvg7DwndQuu6XmfR6hxk0/

40000回学習させた結果

 

Unityの勉強もせなあかんなーーーー

 

わしの愛読書。