LoginSignup
1
1

More than 5 years have passed since last update.

LIS ver.2を入れて使ってみる

Last updated at Posted at 2016-09-19

この情報は古いので、現状のLIS ver.2には適合しない可能性があります。

環境

GPU GTX1070
ubuntu 14.04
chainer 1.14.0
など

はじめに

過去12回でパソコンを自作した後に、Ubuntu14.04、CUDA、cuDNN、chainer、dqn、LIS、Tensorflow、OpenAIGymを順次インストールし、いくつかモデルを走らせた。特に前回はModel-Free Episodic Controlを学習させた。
http://qiita.com/masataka46/items/a87110e8665f29f751f5

今回はドワンゴさんのLISのヴァージョン2をインストールし、使ってみる。コードはこちらのpull requestにある。
https://github.com/wbap/lis/pull/16

LIS ver.2をインストールする

ver.2のpull requestがmergeされてないようなので、fetchで持ってくる。
LISのver.2はこちらにある。
https://github.com/stssg526/lis/tree/lisver2
適当なディレクトリにgit cloneする。

git clone https://github.com/stssg526/lis.git

しかしなぜかgym_clientがない。ver1なのか?よって、zipファイルから行う。

unzip lis-lisver2

本来ここでpython modulesをinstallする必要がある。

pip install -r python-agent/requirements.txt

これを怠ったことが後のエラーに繋がったか?

次にdataをfetchする。

./fetch.sh

ver2はUnityがサーバーになったので、先に起動する。

cd PATH_TO_UNITY_EDITOR
./Unity

次にクライアントのagent側を起動する。

cd gym_client/examples/agents
PYTHONPATH=../../ python Lis_dqn.py

本来これで学習が開始される。

エラーの対応

学習を開始すると以下のエラーが表示された。

ImportError: No module named websocket

とりあえずpipで入れてみる。

sudo pip install websocket

これで再度実行すると、すると以下のエラーが表示された。

File "/media/ohmasa/several data/home/ohmasa/lisV2/lis-lisver2/gym_client/gym/envs/unity/gym_unity_env.py", line 62, in close
    self.ws.close()  # コネクション終了
AttributeError: 'GymUnityEnv' object has no attribute 'ws'

gym_unity_env.pyの16行目には以下のように書かれている。

self.ws = websocket.create_connection("ws://localhost:4649/CommunicationGym")

wsというインスタンス変数はあるが、これにwebsocketどうたらを代入しているのが気になる。先ほどインストールしたwebsocketに問題あるのだろうか?

READMEの下方Module Referencesにwebsocket-sharpとかwebsocket-clientとかある。これは先ほど入れたwebsocketとは別物なのだろうか?とりあえずwebsocket-clientを入れてみる。

sudo pip install websocket-client

再度実行すると、ようやく学習が始まった。しかししばらくすると

msgpack.exceptions.UnpackValueError: Unpack failed: error = 0

となって止まった。Referencesにmsg-packどうたらこうたら書いているが、これが問題だろうか。そこで

sudo easy_install msgpack-python

として再度実行。しかしやっぱり同じエラーが出る。そこでネットで調べたところ、このサイト
http://qiita.com/snaka/items/8da9f89deeef17b1923a
など読むと、msgpack-unityというものが別にあるらしい。
確かにREADMEにはmsgpack-unityと書かれていた。そこでGitHubのここ
https://github.com/masharada/msgpack-unity
を利用する。

git clone https://github.com/masharada/msgpack-unity.git

このsrcフォルダを対応するunityのプロジェクトのAssetsフォルダ内にコピーした。再度実行すると、Unityを立ち上げた際にウインドウ下部に以下のエラーが表示され、ゲームの進行が出来なかった。

Assets/Packages/mspack-unity/src/BoxingPacker.cs(25,22):error CS0101:The namespace 'MsgPack' already contains a difinition for 'BoxingPacker'

問題は自己解決した。LIS ver2の最新版をzip経由で入れた上で、READMEに従って進めると、問題なく学習が進んだ。これまでpython modulesをinstallしてなかったので、これが原因の可能性もある。fetch.shを実行する前に以下を実行する必要があるが忘れていた。

pip install -r python-agent/requirements.txt

学習結果のグラフを表示する

timestep-rewardのグラフを表示する。はじめにpandasをインストールする。

sudo pip install pandas
cd gym_client/examples/agents
python plot_reward_log.py

これで以下のグラフが表示された。
figure_1.png

4万回くらいまで順調に増加してるけど、その後停滞してるね。13万回くらい学習するのにGPU使って6時間半。

1
1
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
1
1