0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

強化学習38 OpenAI Atari Ramバージョンの特徴

Last updated at Posted at 2019-12-18

中学生から大学生のAI初学者が対象です。

Atariのenvでどれを選択すればいいのだろうか?
それぞれの違いは、こちらに詳しく書かれています。
https://qiita.com/keisuke-nakata/items/141fc53f419b102d942c

これを見る限り、以下の順番でやってみると良さそうです。
1 Breakout-ramNoFrameskip-v4
2 BreakoutNoFrameskip-v4
3 それ以外。
それ以外が何のためにあるのか分かりませんが。

chokozainerRLは、chainerRLのexampleをコピーして、魔改造しています。
そのため、train_dqn_aleは、NoFrameskip限定の、
chainerrl.wrappers.atari_wrappers.make_atariを使います。

この強化学習シリーズもOpenAIのAtariを始めていますが、率直に大変です。
まず、画像処理を伴わないRamバージョンでの学習を試みていますが、10000 episodesくらいではダメですね。Ramバージョンで学習させている報告が少ないので、画像バージョンを基本に考えていきます。

画像ヴァージョンで、いろいろと紹介されている方法では、
4回分のstepを1つにまとめるようなwrapperを使っています。

例えば、ChainerRLでatariのゲームをDQNで解いてみよう
https://chainer-colab-notebook.readthedocs.io/ja/latest/notebook/hands_on/chainerrl/atari_sample.html

こちらのale.ALEは、default設定で4回になっています。

breakoutはラケットで跳ね返したボールが、壁に当たるまでにかなりのstepがかかるので、gamma=0.99でも、Q判定が難しくなります。なので、4回に1回にすれば、学習効率が上がりそうです。

chainerrl/wrappers/atari_wrappers
のMaxAndSkipEnvは、Ramバージョンでは使えないので、
下のように魔改造します。

class MaxAndSkipEnvRam(gym.Wrapper):
    def __init__(self, env, skip=4):
        """Return only every `skip`-th frame"""
        gym.Wrapper.__init__(self, env)
        # most recent raw observations (for max pooling across time steps)
        self._obs = None
        self._skip = skip

    def step(self, action):
        """Repeat action, sum reward, and max over last observations."""
        total_reward = 0.0
        done = None
        for i in range(self._skip):
            self.obs, reward, done, info = self.env.step(action)
            total_reward += reward
            if done or info.get('needs_reset', False):
                break
        return self.obs, total_reward, done, info

    def reset(self, **kwargs):
        return self.env.reset(**kwargs)

それでも学習は単純なDQNでは難航しそうなので、Ramバージョンはオススメできません。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?