1
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 3 years have passed since last update.

Stable Baselines導入メモ

Last updated at Posted at 2020-11-23

##Stable Baselines

$ conda create -n baseline python=3.6 anaconda
$ conda activate baseline
(baseline) > pip install tensorflow-gpu==1.14.0
(baseline) > pip install gym
(baseline) > pip install stable-baselines[mpi]
(baseline) > pip install pyqt5
(baseline) > pip install imageio

imageioはいらないかも。[mpi]は動かない可能性が高いので、MSMPIを以下からインストールする(win)
https://www.microsoft.com/en-us/download/details.aspx?id=56727
msmpisetup.exe と msmpisdk.msi の両方をダウンロードして実行する。前者で MPI を実行する用のファイルがインストールされ、後者で MPI を使ったプログラムを作るのに必要なヘッダやライブラリがインストールされる。
##動作確認
以下のファイルを作って動けばok

hello_baselines.py
import gym
from stable_baselines.common.vec_env import DummyVecEnv
from stable_baselines import PPO2
env = gym.make("CartPole-v1")
env = DummyVecEnv([lambda: env])
model = PPO2('MlpPolicy', env, verbose=1)
model.learn(total_timesteps=100000)
state = env.reset()
for i in range(200):
    env.render()
    action, _ = model.predict(state, deterministic=True)
    state, rewards, done, info = env.step(action)
    if done:
        break
env.close()

#参考
##Stable-baselines

Name 中央揃え 右揃え
A2C align-center align-right
ACER align-center align-right
ACKTR align-center align-right
DDPG align-center align-right
DQN align-center align-right
HER align-center align-right
GAIL align-center align-right
PPO1 align-center align-right
PPO2 align-center align-right
SAC align-center align-right
TRPO align-center align-right

##keras-rl

Name 中央揃え 右揃え
DQN align-center align-right
DDPG align-center align-right
NAF align-center align-right
CEM align-center align-right
SARSA align-center align-right
1
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
1
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?