RL_tutorial

Similar documents
放射線専門医認定試験(2009・20回)/HOHS‐05(基礎二次)

プログラム

日本内科学会雑誌第98巻第4号

日本内科学会雑誌第97巻第7号

日本内科学会雑誌第98巻第3号

30


P1〜14/稲 〃

Python Speed Learning

Ł\”ƒ-2005

第90回日本感染症学会学術講演会抄録(I)

PYTHON 資料 電脳梁山泊烏賊塾 PYTHON 入門 ゲームプログラミング スプライトの衝突判定 スプライトの衝突判定 スプライトの衝突判定の例として インベーダーゲームのコードを 下記に示す PYTHON3 #coding: utf-8 import pygame from pygame.lo

日本内科学会雑誌第102巻第4号

プログラム


平成20年5月 協会創立50年の歩み 海の安全と環境保全を目指して 友國八郎 海上保安庁 長官 岩崎貞二 日本船主協会 会長 前川弘幸 JF全国漁業協同組合連合会 代表理事会長 服部郁弘 日本船長協会 会長 森本靖之 日本船舶機関士協会 会長 大内博文 航海訓練所 練習船船長 竹本孝弘 第二管区海上保安本部長 梅田宜弘

Program

aphp37-11_プロ1/ky869543540410005590


日本内科学会雑誌第96巻第11号

Œ{ٶ/1ŒÊ −ªfiª„¾ [ 1…y†[…W ]

第86回日本感染症学会総会学術集会後抄録(II)

17. (1) 18. (1) 19. (1) 20. (1) 21. (1) (3) 22. (1) (3) 23. (1) (3) (1) (3) 25. (1) (3) 26. (1) 27. (1) (3) 28. (1) 29. (1) 2

ジェネリック医薬品販売会社(田辺製薬販売株式会社)の設立に伴う包装変更のご案内

06地図目録.pwd

cards.gif from Tkinter import * root = Tk() c0 = Canvas(root, width = 400, height = 300) c0.pack() image_data = PhotoImage(file = c1.gif ) c0.create_i

:56 1 (Forward kinematics) (Global frame) G r = (X, Y, Z) (Local frame) L r = (x, y, z) 1 X Y, Z X Y, Z 1 ( ) ( ) 1.2 (Joint rotati

from Tkinter import * root = Tk() c0 = Canvas(root, width = 400, height = 300) c0.pack() image_data = PhotoImage(file = c1.gif ) c0.create_image(200,

Python Speed Learning

IPSJ SIG Technical Report Vol.2016-GI-35 No /3/9 StarCraft AI Deep Q-Network StarCraft: BroodWar Blizzard Entertainment AI Competition AI Convo

離散数理工学 第 2回 数え上げの基礎:漸化式の立て方

8-7th

日本内科学会雑誌第102巻第10号


Visual Python, Numpy, Matplotlib

Anaconda (2019/7/3)


PowerPoint プレゼンテーション

listings-ext

19 3!! (+) (>) (++) (+=) for while 3.1!! (20, 20) (1)(Blocks1.java) import javax.swing.japplet; import java.awt.graphics;

第85 回日本感染症学会総会学術集会後抄録(III)


日歯雑誌(H19・5月号)済/P6‐16 クリニカル  柿木 5

O1-1 O1-2 O1-3 O1-4 O1-5 O1-6

lifedesign_contest_No3

or a 3-1a (0 b ) : max: a b a > b result a result b ( ) result Python : def max(a, b): if a > b: result = a else: result = b ret

9 rbenv rbenv ruby 9.1 rbenv rbenv rbenv ruby ruby-build ruby 9.2 rbenv macos.bash_profile ~/.bash_profile ~/.bash_profile.bak $ touch ~/.bash_profile

: Shift-Return evaluate 2.3 Sage? Shift-Return abs 2 abs? 2: abs 3: fac

CuPy とは何か?

第86回日本感染症学会総会学術集会後抄録(I)

Visual Python, Numpy, Matplotlib

アンリツ株式会社様

Java演習(4) -- 変数と型 --

EnSight 10.1の新機能


Emacs Ruby..

Python C/C++ IPMU IRAF

1 matplotlib matplotlib Python matplotlib numpy matplotlib Installing A 2 pyplot matplotlib 1 matplotlib.pyplot matplotlib.pyplot plt import import nu

Transcription:

)! " = $ % & ' "(& &*+ = ' " + %' "(- + %. ' "(. + γ γ=0! " = $ " γ=0.9! " = $ " + 0.9$ " + 0.81$ "+, +

! " #, % #! " #, % # + (( + #,- +. max 2 3! " #,-, % 4! " #, % # ) α

! " #, % ' ( )(#, %)! "#," %,," ' (, ) +, -., ( + 0 -. 0 (+ 1 -. 1 (, ) ) )

! " #, % #! " #, % # + (( + #,- +. max 2 3! " #,-, % 4! " #, % # )

! " #, % #! " #, % # + (( + #,- +. max 2 3! " #,-, % 4! " #, % # ) " #$% + '((* #$%, argmax 1 2( * #$%, 3; 5 #, 5 # 6 )

! ", $ & ' + ) max! " '-., $! ", $ & ' + )& '*+ + ), max!(" '*,, $)

1. 2. 3. 4. 5. 6.

git clone https://github.com/openai/gym.git cd gym // pip install e. // pip install e.[all]

import gym env = gym.make( CartPole-v0 ) env.reset() // env.render() //

import gym env = gym.make( CartPole-v0 ) env.reset() // for _ in range(1000): env.render() action = env.action_space.sample() // env.step(action) //

import chainer import chainer.functions as F import chainer.links as L import chainerrl import gym import numpy as np

env = gym.make('cartpole-v0 ) print("observation space : {}".format(env.observation_space)) print("action space : {}".format(env.action_space)) obs = env.reset() env.render() print( observation : {}.format(obs)) observation space : Box(4,) action space : Discrete(2) observation : [-0.0169323-0.0251642-0.039872 0.0498410]

class QFunction(chainer.Chain): def init (self, obs_size, n_actions, n_hidden_channels=50): # For Python 2.* super(qfunction, self). init ( # For Python 3.* super(self). init ( l0=l.linear(obs_size, n_hidden_channels), l1=l.linear(n_hidden_channels,n_hidden_channels), l2=l.linear(n_hidden_channels, n_actions)) def call (self, x): h = F.tanh(self.l0(x)) h = F.tanh(self.l1(h)) return chainerrl.action_value.discreteactionvalue(self.l2(h)) obs_size = env.observation_space.shape[0] n_actions = env.action_space.n q_func = QFunction(obs_size, n_actions) # GPU q_func.to_gpu(0)

# optimizer = chainer.optimizers.adam(eps=1e-2) optimizer.setup(q_func) # gamma = 0.95 # epsilon greedy explorer = chainerrl.explorers.constantepsilongreedy( epsilon=0.3, random_action_func=env.action_space.sample) # experience replay replay_buffer = chainerrl.replay_buffer.replaybuffer(capacity = 10**6) phi = lambda x:x.astype(np.float32, copy=false) agent = chainerrl.agents.dqn( q_func, optimizer, replay_buffer, gamma, explorer, replay_start_size=500, update_interval=1, target_update_interval=100, phi=phi)

for i in range(1, 200 + 1): obs = env.reset() reward = 0 done = False R = 0 t = 0 while not done and t < 200: env.render() action = agent.act_and_train(obs.astype(np.float32), reward) obs, reward, done, _ = env.step(action) R += reward t += 1 agent.stop_episode_and_train(obs, reward, done) # agent.save( filename )

for i in range(10): obs = env.reset() done = False R = 0 t = 0 while not done and t < 200: env.render() action = agent.act(obs.astype(np.float32)) obs, r, done, _ = env.step(action) R += r t += 1 print('test episode:', i, 'R:', R) agent.stop_episode()

1.

1. 2.

1. 2. 3.