├── .DS_Store ├── README.md ├── modulabs_lecture └── 모두연 저자특강.pdf ├── naver_seminar └── RLCode와 A3C 쉽고 깊게 이해하기.pdf ├── snu_lecture ├── .DS_Store ├── code │ ├── deep-sarsa │ │ ├── __pycache__ │ │ │ └── environment.cpython-35.pyc │ │ ├── deep_sarsa_agent.py │ │ ├── deep_sarsa_exercise1.py │ │ ├── deep_sarsa_exercise2.py │ │ ├── environment.py │ │ ├── save_graph │ │ │ ├── deep_sarsa_.png │ │ │ └── deep_sarsa_trained.png │ │ └── save_model │ │ │ ├── deep_sarsa.h5 │ │ │ └── deep_sarsa_trained.h5 │ ├── img │ │ ├── circle.png │ │ ├── down.png │ │ ├── left.png │ │ ├── rectangle.png │ │ ├── right.png │ │ ├── triangle.png │ │ └── up.png │ ├── keras_example │ │ └── sequential_model.py │ └── q-learning │ │ ├── .python-version │ │ ├── __pycache__ │ │ ├── environment.cpython-35.pyc │ │ └── environment.cpython-36.pyc │ │ ├── environment.py │ │ ├── q_learning_agent.py │ │ ├── q_learning_exercise1.py │ │ └── q_learning_exercise2.py ├── install_guide │ ├── .DS_Store │ ├── README.md │ ├── img │ │ ├── how-to-windows.png │ │ ├── link-env-with-pychar-1.png │ │ ├── link-env-with-pychar-2.png │ │ ├── link-env-with-pychar.png │ │ ├── numpy_install.png │ │ ├── numpy_install2.png │ │ ├── numpy_install3.png │ │ ├── python3png.png │ │ ├── python_install.png │ │ ├── win_atari.png │ │ ├── win_atari.py3.png │ │ ├── win_breakout.png │ │ ├── win_breakout2.png │ │ ├── win_git.png │ │ ├── win_git2.png │ │ ├── win_gym.png │ │ ├── win_make.png │ │ ├── win_make2.png │ │ ├── win_msys2.png │ │ ├── win_msys2_2.png │ │ ├── win_msys2_3.png │ │ ├── win_msys2_4.png │ │ ├── win_msys2_5.png │ │ ├── win_openai_gym.png │ │ ├── win_openai_gym2.png │ │ ├── win_openai_gym3.png │ │ ├── win_openai_gym4.png │ │ ├── win_openai_gym5.png │ │ ├── win_pycharm_install1.png │ │ ├── win_pycharm_project.png │ │ ├── win_pycharm_project2.png │ │ ├── win_pycharm_setting2.png │ │ ├── win_pycharm_settings.png │ │ ├── win_setting.png │ │ ├── win_setting2.png │ │ ├── win_setting3.png │ │ ├── win_setting4.png │ │ ├── win_setup.py.png │ │ ├── win_setup.py2.png │ │ └── win_xming.png │ ├── install_image │ │ ├── .DS_Store │ │ ├── atari_breakout.png │ │ ├── cartpole_exam.png │ │ ├── console_hello_world.png │ │ ├── deep_sarsa.png │ │ ├── deep_sarsa_run.png │ │ ├── deep_sarsa_run2.png │ │ ├── default_config.png │ │ ├── file_setting.png │ │ ├── hello_world_ubuntu.png │ │ ├── install_keras.PNG │ │ ├── install_matplotlib.PNG │ │ ├── install_numpy.PNG │ │ ├── install_pillow.PNG │ │ ├── install_tensorflow.PNG │ │ ├── openai_github.png │ │ ├── project_interpreter.png │ │ ├── pycham_new_project.png │ │ ├── pycharm_community.png │ │ ├── pycharm_drag.png │ │ ├── pycharm_init.png │ │ ├── python3_terminal.jpg │ │ ├── python_download.png │ │ ├── python_installed.png │ │ ├── python_intalled.png │ │ ├── q_learning.png │ │ ├── q_learning_run.png │ │ ├── rl_book_hello_world.png │ │ ├── rl_book_project.png │ │ ├── rl_book_venv.png │ │ ├── rl_book_virtualenv.png │ │ ├── rlcode_book_directory.png │ │ ├── rlcode_project.png │ │ ├── run_hello_world.png │ │ ├── sh_pycharm.sh.png │ │ └── terminal_rlcode_book.png │ ├── 맥_설치가이드.md │ ├── 우분투_설치가이드.md │ └── 윈도우10_설치가이드.md └── 서울대학교 인지과학 튜토리얼.pdf └── wiki ├── .DS_Store ├── README.md ├── img ├── how-to-windows.png ├── link-env-with-pychar-1.png ├── link-env-with-pychar-2.png ├── link-env-with-pychar.png ├── numpy_install.png ├── numpy_install2.png ├── numpy_install3.png ├── python3png.png ├── python_install.png ├── win_atari.png ├── win_atari.py3.png ├── win_breakout.png ├── win_breakout2.png ├── win_git.png ├── win_git2.png ├── win_gym.png ├── win_make.png ├── win_make2.png ├── win_msys2.png ├── win_msys2_2.png ├── win_msys2_3.png ├── win_msys2_4.png ├── win_msys2_5.png ├── win_openai_gym.png ├── win_openai_gym2.png ├── win_openai_gym3.png ├── win_openai_gym4.png ├── win_openai_gym5.png ├── win_pycharm_install1.png ├── win_pycharm_project.png ├── win_pycharm_project2.png ├── win_pycharm_setting2.png ├── win_pycharm_settings.png ├── win_setting.png ├── win_setting2.png ├── win_setting3.png ├── win_setting4.png ├── win_setup.py.png ├── win_setup.py2.png └── win_xming.png ├── install_image ├── .DS_Store ├── atari_breakout.png ├── cartpole_exam.png ├── console_hello_world.png ├── deep_sarsa_run.png ├── deep_sarsa_run2.png ├── default_config.png ├── file_setting.png ├── hello_world_ubuntu.png ├── install_keras.PNG ├── install_matplotlib.PNG ├── install_numpy.PNG ├── install_pillow.PNG ├── install_tensorflow.PNG ├── openai_github.png ├── project_interpreter.png ├── pycham_new_project.png ├── pycharm_community.png ├── pycharm_drag.png ├── pycharm_init.png ├── python3_terminal.jpg ├── python_download.png ├── python_installed.png ├── python_intalled.png ├── rl_book_hello_world.png ├── rl_book_project.png ├── rl_book_venv.png ├── rl_book_virtualenv.png ├── rlcode_book_directory.png ├── rlcode_project.png ├── run_hello_world.png ├── sh_pycharm.sh.png └── terminal_rlcode_book.png ├── 맥_설치가이드.md ├── 우분투_설치가이드.md └── 윈도우10_설치가이드.md /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/.DS_Store -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RLCode_tutorial 2 | RLCode 강화학습 튜토리얼 및 강의 자료들입니다 3 | -------------------------------------------------------------------------------- /modulabs_lecture/모두연 저자특강.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/modulabs_lecture/모두연 저자특강.pdf -------------------------------------------------------------------------------- /naver_seminar/RLCode와 A3C 쉽고 깊게 이해하기.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/naver_seminar/RLCode와 A3C 쉽고 깊게 이해하기.pdf -------------------------------------------------------------------------------- /snu_lecture/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/.DS_Store -------------------------------------------------------------------------------- /snu_lecture/code/deep-sarsa/__pycache__/environment.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/code/deep-sarsa/__pycache__/environment.cpython-35.pyc -------------------------------------------------------------------------------- /snu_lecture/code/deep-sarsa/deep_sarsa_agent.py: -------------------------------------------------------------------------------- 1 | import pylab 2 | import random 3 | import numpy as np 4 | from environment import Env 5 | from keras.layers import Dense 6 | from keras.optimizers import Adam 7 | from keras.models import Sequential 8 | 9 | EPISODES = 1000 10 | 11 | 12 | # 그리드월드 예제에서의 딥살사 에이전트 13 | class DeepSARSAgent: 14 | def __init__(self): 15 | # 에이전트가 가능한 모든 행동 정의 16 | self.action_space = [0, 1, 2, 3, 4] 17 | # 상태의 크기와 행동의 크기 정의 18 | self.action_size = len(self.action_space) 19 | self.state_size = 15 20 | self.discount_factor = 0.99 21 | self.learning_rate = 0.001 22 | 23 | # 탐험 관련 24 | self.epsilon = 1. 25 | self.epsilon_decay = .9999 26 | self.epsilon_min = 0.01 27 | # 모델 생성 28 | self.model = self.build_model() 29 | 30 | # 상태가 입력 큐함수가 출력인 인공신경망 생성 31 | def build_model(self): 32 | model = Sequential() 33 | model.add(Dense(30, input_dim=self.state_size, activation='relu')) 34 | model.add(Dense(30, activation='relu')) 35 | model.add(Dense(self.action_size, activation='linear')) 36 | model.summary() 37 | model.compile(loss='mse', optimizer=Adam(lr=self.learning_rate)) 38 | return model 39 | 40 | # 입실론 탐욕 방법으로 행동 선택 41 | def get_action(self, state): 42 | if random.random() <= self.epsilon: 43 | # 무작위 행동 반환 44 | action = random.choice(self.action_space) 45 | return action 46 | else: 47 | # 모델로부터 행동 산출 48 | state = np.float32(state) 49 | q_values = self.model.predict(state)[0] 50 | return np.argmax(q_values) 51 | 52 | def train_model(self, state, action, reward, next_state, next_action, done): 53 | state = np.float32(state) 54 | next_state = np.float32(next_state) 55 | 56 | # 살사의 큐함수 업데이트 식 57 | target = self.model.predict(state)[0] 58 | if done: 59 | target[action] = reward 60 | else: 61 | target[action] = (reward + self.discount_factor * 62 | self.model.predict(next_state)[0][next_action]) 63 | 64 | # 출력 값 reshape 65 | target = np.reshape(target, [1, self.action_size]) 66 | # 인공신경망 업데이트 67 | self.model.fit(state, target, epochs=1, verbose=0) 68 | 69 | 70 | if __name__ == "__main__": 71 | # 환경과 에이전트 생성 72 | env = Env() 73 | agent = DeepSARSAgent() 74 | 75 | global_step = 0 76 | scores, episodes = [], [] 77 | 78 | for e in range(EPISODES): 79 | done = False 80 | score = 0 81 | state = env.reset() 82 | state = np.reshape(state, [1, 15]) 83 | 84 | while not done: 85 | # env 초기화 86 | global_step += 1 87 | if agent.epsilon > agent.epsilon_min: 88 | agent.epsilon *= agent.epsilon_decay 89 | 90 | # 현재 상태에 대한 행동 선택 91 | action = agent.get_action(state) 92 | # 선택한 행동으로 환경에서 한 타임스텝 진행 후 샘플 수집 93 | next_state, reward, done = env.step(action) 94 | next_state = np.reshape(next_state, [1, 15]) 95 | next_action = agent.get_action(next_state) 96 | # 샘플로 모델 학습 97 | agent.train_model(state, action, reward, next_state, next_action, 98 | done) 99 | state = next_state 100 | score += reward 101 | 102 | if done: 103 | # 에피소드마다 학습 결과 출력 104 | scores.append(score) 105 | episodes.append(e) 106 | pylab.plot(episodes, scores, 'b') 107 | pylab.savefig("./save_graph/deep_sarsa_.png") 108 | print("episode:", e, " score:", score, "global_step", 109 | global_step, " epsilon:", agent.epsilon) 110 | 111 | # 100 에피소드마다 모델 저장 112 | if e % 100 == 0: 113 | agent.model.save_weights("./save_model/deep_sarsa.h5") 114 | -------------------------------------------------------------------------------- /snu_lecture/code/deep-sarsa/deep_sarsa_exercise1.py: -------------------------------------------------------------------------------- 1 | from environment import Env 2 | import random 3 | 4 | if __name__ == "__main__": 5 | # 환경과 에이전트 생성 6 | env = Env() 7 | 8 | for episode in range(10): 9 | print('episode ' + str(episode) + ' ----------------') 10 | done = False 11 | state = env.reset() 12 | 13 | while not done: 14 | # 랜덤하게 행동 선택 15 | action = random.choice([0, 1, 2, 3, 4]) 16 | # 선택한 행동으로 환경에서 한 타임스텝 진행 17 | state, reward, done = env.step(action) 18 | 19 | print('state: ', state, ' action: ', action, ' reward: ', reward) 20 | 21 | if done: 22 | break 23 | -------------------------------------------------------------------------------- /snu_lecture/code/deep-sarsa/deep_sarsa_exercise2.py: -------------------------------------------------------------------------------- 1 | import random 2 | import numpy as np 3 | from environment import Env 4 | from keras.layers import Dense 5 | from keras.optimizers import Adam 6 | from keras.models import Sequential 7 | 8 | EPISODES = 1000 9 | 10 | 11 | # 그리드월드 예제에서의 딥살사 에이전트 12 | class DeepSARSAgent: 13 | def __init__(self): 14 | # 에이전트가 가능한 모든 행동 정의 15 | self.action_space = [0, 1, 2, 3, 4] 16 | # 상태의 크기와 행동의 크기 정의 17 | self.action_size = len(self.action_space) 18 | self.state_size = 15 19 | self.discount_factor = 0.99 20 | self.learning_rate = 0.001 21 | 22 | # 탐험 관련 23 | self.epsilon = 1. 24 | self.epsilon_decay = .9999 25 | self.epsilon_min = 0.01 26 | 27 | # 모델 생성 28 | 29 | # 상태가 입력 큐함수가 출력인 인공신경망 생성 30 | def build_model(self): 31 | pass 32 | 33 | # 입실론 탐욕 방법으로 행동 선택 34 | def get_action(self, state): 35 | pass 36 | 37 | def train_model(self, state, action, reward, next_state, next_action, done): 38 | state = np.float32(state) 39 | next_state = np.float32(next_state) 40 | 41 | # 살사의 큐함수 업데이트 식 42 | 43 | # 출력 값 reshape 44 | 45 | # 인공신경망 업데이트 46 | 47 | 48 | if __name__ == "__main__": 49 | # 환경과 에이전트 생성 50 | env = Env() 51 | agent = DeepSARSAgent() 52 | 53 | global_step = 0 54 | scores, episodes = [], [] 55 | 56 | for e in range(EPISODES): 57 | done = False 58 | score = 0 59 | state = env.reset() 60 | state = np.reshape(state, [1, 15]) 61 | 62 | while not done: 63 | # env 초기화 64 | global_step += 1 65 | if agent.epsilon > agent.epsilon_min: 66 | agent.epsilon *= agent.epsilon_decay 67 | 68 | # 현재 상태에 대한 행동 선택 69 | 70 | # 선택한 행동으로 환경에서 한 타임스텝 진행 후 샘플 수집 71 | 72 | # 샘플로 모델 학습 73 | 74 | if done: 75 | # 에피소드마다 학습 결과 출력 76 | break 77 | 78 | # 100 에피소드마다 모델 저장 79 | -------------------------------------------------------------------------------- /snu_lecture/code/deep-sarsa/environment.py: -------------------------------------------------------------------------------- 1 | import time 2 | import numpy as np 3 | import tkinter as tk 4 | from PIL import ImageTk, Image 5 | 6 | PhotoImage = ImageTk.PhotoImage 7 | UNIT = 50 # 픽셀 수 8 | HEIGHT = 5 # 그리드 세로 9 | WIDTH = 5 # 그리드 가로 10 | 11 | np.random.seed(1) 12 | 13 | 14 | class Env(tk.Tk): 15 | def __init__(self): 16 | super(Env, self).__init__() 17 | self.action_space = ['u', 'd', 'l', 'r'] 18 | self.action_size = len(self.action_space) 19 | self.title('DeepSARSA') 20 | self.geometry('{0}x{1}'.format(HEIGHT * UNIT, HEIGHT * UNIT)) 21 | self.shapes = self.load_images() 22 | self.canvas = self._build_canvas() 23 | self.counter = 0 24 | self.rewards = [] 25 | self.goal = [] 26 | # 장애물 설정 27 | self.set_reward([0, 1], -1) 28 | self.set_reward([1, 2], -1) 29 | self.set_reward([2, 3], -1) 30 | # 목표 지점 설정 31 | self.set_reward([4, 4], 1) 32 | 33 | def _build_canvas(self): 34 | canvas = tk.Canvas(self, bg='white', 35 | height=HEIGHT * UNIT, 36 | width=WIDTH * UNIT) 37 | # 그리드 생성 38 | for c in range(0, WIDTH * UNIT, UNIT): # 0~400 by 80 39 | x0, y0, x1, y1 = c, 0, c, HEIGHT * UNIT 40 | canvas.create_line(x0, y0, x1, y1) 41 | for r in range(0, HEIGHT * UNIT, UNIT): # 0~400 by 80 42 | x0, y0, x1, y1 = 0, r, HEIGHT * UNIT, r 43 | canvas.create_line(x0, y0, x1, y1) 44 | 45 | self.rewards = [] 46 | self.goal = [] 47 | # 캔버스에 이미지 추가 48 | x, y = UNIT/2, UNIT/2 49 | self.rectangle = canvas.create_image(x, y, image=self.shapes[0]) 50 | 51 | canvas.pack() 52 | 53 | return canvas 54 | 55 | def load_images(self): 56 | rectangle = PhotoImage( 57 | Image.open("../img/rectangle.png").resize((30, 30))) 58 | triangle = PhotoImage( 59 | Image.open("../img/triangle.png").resize((30, 30))) 60 | circle = PhotoImage( 61 | Image.open("../img/circle.png").resize((30, 30))) 62 | 63 | return rectangle, triangle, circle 64 | 65 | def reset_reward(self): 66 | 67 | for reward in self.rewards: 68 | self.canvas.delete(reward['figure']) 69 | 70 | self.rewards.clear() 71 | self.goal.clear() 72 | self.set_reward([0, 1], -1) 73 | self.set_reward([1, 2], -1) 74 | self.set_reward([2, 3], -1) 75 | 76 | # #goal 77 | self.set_reward([4, 4], 1) 78 | 79 | def set_reward(self, state, reward): 80 | state = [int(state[0]), int(state[1])] 81 | x = int(state[0]) 82 | y = int(state[1]) 83 | temp = {} 84 | if reward > 0: 85 | temp['reward'] = reward 86 | temp['figure'] = self.canvas.create_image((UNIT * x) + UNIT / 2, 87 | (UNIT * y) + UNIT / 2, 88 | image=self.shapes[2]) 89 | 90 | self.goal.append(temp['figure']) 91 | 92 | 93 | elif reward < 0: 94 | temp['direction'] = -1 95 | temp['reward'] = reward 96 | temp['figure'] = self.canvas.create_image((UNIT * x) + UNIT / 2, 97 | (UNIT * y) + UNIT / 2, 98 | image=self.shapes[1]) 99 | 100 | temp['coords'] = self.canvas.coords(temp['figure']) 101 | temp['state'] = state 102 | self.rewards.append(temp) 103 | 104 | # new methods 105 | 106 | def check_if_reward(self, state): 107 | check_list = dict() 108 | check_list['if_goal'] = False 109 | rewards = 0 110 | 111 | for reward in self.rewards: 112 | if reward['state'] == state: 113 | rewards += reward['reward'] 114 | if reward['reward'] == 1: 115 | check_list['if_goal'] = True 116 | 117 | check_list['rewards'] = rewards 118 | 119 | return check_list 120 | 121 | def coords_to_state(self, coords): 122 | x = int((coords[0] - UNIT / 2) / UNIT) 123 | y = int((coords[1] - UNIT / 2) / UNIT) 124 | return [x, y] 125 | 126 | def reset(self): 127 | self.update() 128 | time.sleep(0.5) 129 | x, y = self.canvas.coords(self.rectangle) 130 | self.canvas.move(self.rectangle, UNIT / 2 - x, UNIT / 2 - y) 131 | self.reset_reward() 132 | return self.get_state() 133 | 134 | def step(self, action): 135 | self.counter += 1 136 | self.render() 137 | 138 | if self.counter % 2 == 1: 139 | self.rewards = self.move_rewards() 140 | 141 | next_coords = self.move(self.rectangle, action) 142 | check = self.check_if_reward(self.coords_to_state(next_coords)) 143 | done = check['if_goal'] 144 | reward = check['rewards'] 145 | 146 | self.canvas.tag_raise(self.rectangle) 147 | 148 | s_ = self.get_state() 149 | 150 | return s_, reward, done 151 | 152 | def get_state(self): 153 | 154 | location = self.coords_to_state(self.canvas.coords(self.rectangle)) 155 | agent_x = location[0] 156 | agent_y = location[1] 157 | 158 | states = list() 159 | 160 | for reward in self.rewards: 161 | reward_location = reward['state'] 162 | states.append(reward_location[0] - agent_x) 163 | states.append(reward_location[1] - agent_y) 164 | if reward['reward'] < 0: 165 | states.append(-1) 166 | states.append(reward['direction']) 167 | else: 168 | states.append(1) 169 | 170 | return states 171 | 172 | def move_rewards(self): 173 | new_rewards = [] 174 | for temp in self.rewards: 175 | if temp['reward'] == 1: 176 | new_rewards.append(temp) 177 | continue 178 | temp['coords'] = self.move_const(temp) 179 | temp['state'] = self.coords_to_state(temp['coords']) 180 | new_rewards.append(temp) 181 | return new_rewards 182 | 183 | def move_const(self, target): 184 | 185 | s = self.canvas.coords(target['figure']) 186 | 187 | base_action = np.array([0, 0]) 188 | 189 | if s[0] == (WIDTH - 1) * UNIT + UNIT / 2: 190 | target['direction'] = 1 191 | elif s[0] == UNIT / 2: 192 | target['direction'] = -1 193 | 194 | if target['direction'] == -1: 195 | base_action[0] += UNIT 196 | elif target['direction'] == 1: 197 | base_action[0] -= UNIT 198 | 199 | if (target['figure'] is not self.rectangle 200 | and s == [(WIDTH - 1) * UNIT, (HEIGHT - 1) * UNIT]): 201 | base_action = np.array([0, 0]) 202 | 203 | self.canvas.move(target['figure'], base_action[0], base_action[1]) 204 | 205 | s_ = self.canvas.coords(target['figure']) 206 | 207 | return s_ 208 | 209 | def move(self, target, action): 210 | s = self.canvas.coords(target) 211 | 212 | base_action = np.array([0, 0]) 213 | 214 | if action == 0: # 상 215 | if s[1] > UNIT: 216 | base_action[1] -= UNIT 217 | elif action == 1: # 하 218 | if s[1] < (HEIGHT - 1) * UNIT: 219 | base_action[1] += UNIT 220 | elif action == 2: # 우 221 | if s[0] < (WIDTH - 1) * UNIT: 222 | base_action[0] += UNIT 223 | elif action == 3: # 좌 224 | if s[0] > UNIT: 225 | base_action[0] -= UNIT 226 | 227 | self.canvas.move(target, base_action[0], base_action[1]) 228 | 229 | s_ = self.canvas.coords(target) 230 | 231 | return s_ 232 | 233 | def render(self): 234 | # 게임 속도 조정 235 | time.sleep(0.05) 236 | self.update() 237 | -------------------------------------------------------------------------------- /snu_lecture/code/deep-sarsa/save_graph/deep_sarsa_.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/code/deep-sarsa/save_graph/deep_sarsa_.png -------------------------------------------------------------------------------- /snu_lecture/code/deep-sarsa/save_graph/deep_sarsa_trained.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/code/deep-sarsa/save_graph/deep_sarsa_trained.png -------------------------------------------------------------------------------- /snu_lecture/code/deep-sarsa/save_model/deep_sarsa.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/code/deep-sarsa/save_model/deep_sarsa.h5 -------------------------------------------------------------------------------- /snu_lecture/code/deep-sarsa/save_model/deep_sarsa_trained.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/code/deep-sarsa/save_model/deep_sarsa_trained.h5 -------------------------------------------------------------------------------- /snu_lecture/code/img/circle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/code/img/circle.png -------------------------------------------------------------------------------- /snu_lecture/code/img/down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/code/img/down.png -------------------------------------------------------------------------------- /snu_lecture/code/img/left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/code/img/left.png -------------------------------------------------------------------------------- /snu_lecture/code/img/rectangle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/code/img/rectangle.png -------------------------------------------------------------------------------- /snu_lecture/code/img/right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/code/img/right.png -------------------------------------------------------------------------------- /snu_lecture/code/img/triangle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/code/img/triangle.png -------------------------------------------------------------------------------- /snu_lecture/code/img/up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/code/img/up.png -------------------------------------------------------------------------------- /snu_lecture/code/keras_example/sequential_model.py: -------------------------------------------------------------------------------- 1 | from keras.layers import Dense 2 | from keras.models import Sequential 3 | from keras.optimizers import Adam 4 | import numpy as np 5 | 6 | state_size = 15 7 | action_size = 5 8 | batch_size = 100 9 | 10 | x_train = np.random.rand(batch_size, state_size) 11 | y_train = np.random.rand(batch_size, action_size) 12 | 13 | model = Sequential() 14 | model.add(Dense(30, input_dim=state_size, activation='relu')) 15 | model.add(Dense(30, activation='relu')) 16 | model.add(Dense(action_size, activation='linear')) 17 | model.compile(loss='mse', optimizer=Adam(lr=0.001)) 18 | model.summary() 19 | 20 | model.fit(x_train, y_train, batch_size=32, epochs=1) 21 | -------------------------------------------------------------------------------- /snu_lecture/code/q-learning/.python-version: -------------------------------------------------------------------------------- 1 | 3.5.0 2 | -------------------------------------------------------------------------------- /snu_lecture/code/q-learning/__pycache__/environment.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/code/q-learning/__pycache__/environment.cpython-35.pyc -------------------------------------------------------------------------------- /snu_lecture/code/q-learning/__pycache__/environment.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/code/q-learning/__pycache__/environment.cpython-36.pyc -------------------------------------------------------------------------------- /snu_lecture/code/q-learning/environment.py: -------------------------------------------------------------------------------- 1 | import time 2 | import numpy as np 3 | import tkinter as tk 4 | from PIL import ImageTk, Image 5 | 6 | np.random.seed(1) 7 | PhotoImage = ImageTk.PhotoImage 8 | UNIT = 100 # 픽셀 수 9 | HEIGHT = 5 # 그리드월드 세로 10 | WIDTH = 5 # 그리드월드 가로 11 | 12 | 13 | class Env(tk.Tk): 14 | def __init__(self): 15 | super(Env, self).__init__() 16 | self.action_space = ['u', 'd', 'l', 'r'] 17 | self.n_actions = len(self.action_space) 18 | self.title('Q Learning') 19 | self.geometry('{0}x{1}'.format(HEIGHT * UNIT, HEIGHT * UNIT)) 20 | self.shapes = self.load_images() 21 | self.canvas = self._build_canvas() 22 | self.texts = [] 23 | 24 | def _build_canvas(self): 25 | canvas = tk.Canvas(self, bg='white', 26 | height=HEIGHT * UNIT, 27 | width=WIDTH * UNIT) 28 | # 그리드 생성 29 | for c in range(0, WIDTH * UNIT, UNIT): # 0~400 by 80 30 | x0, y0, x1, y1 = c, 0, c, HEIGHT * UNIT 31 | canvas.create_line(x0, y0, x1, y1) 32 | for r in range(0, HEIGHT * UNIT, UNIT): # 0~400 by 80 33 | x0, y0, x1, y1 = 0, r, HEIGHT * UNIT, r 34 | canvas.create_line(x0, y0, x1, y1) 35 | 36 | # 캔버스에 이미지 추가 37 | self.rectangle = canvas.create_image(50, 50, image=self.shapes[0]) 38 | self.triangle1 = canvas.create_image(250, 150, image=self.shapes[1]) 39 | self.triangle2 = canvas.create_image(150, 250, image=self.shapes[1]) 40 | self.circle = canvas.create_image(250, 250, image=self.shapes[2]) 41 | 42 | canvas.pack() 43 | 44 | return canvas 45 | 46 | def load_images(self): 47 | rectangle = PhotoImage( 48 | Image.open("../img/rectangle.png").resize((65, 65))) 49 | triangle = PhotoImage( 50 | Image.open("../img/triangle.png").resize((65, 65))) 51 | circle = PhotoImage( 52 | Image.open("../img/circle.png").resize((65, 65))) 53 | 54 | return rectangle, triangle, circle 55 | 56 | def text_value(self, row, col, contents, action, font='Helvetica', size=10, 57 | style='normal', anchor="nw"): 58 | 59 | if action == 0: 60 | origin_x, origin_y = 7, 42 61 | elif action == 1: 62 | origin_x, origin_y = 85, 42 63 | elif action == 2: 64 | origin_x, origin_y = 42, 5 65 | else: 66 | origin_x, origin_y = 42, 77 67 | 68 | x, y = origin_y + (UNIT * col), origin_x + (UNIT * row) 69 | font = (font, str(size), style) 70 | text = self.canvas.create_text(x, y, fill="black", text=contents, 71 | font=font, anchor=anchor) 72 | return self.texts.append(text) 73 | 74 | def print_value_all(self, q_table): 75 | for i in self.texts: 76 | self.canvas.delete(i) 77 | self.texts.clear() 78 | for i in range(HEIGHT): 79 | for j in range(WIDTH): 80 | for action in range(0, 4): 81 | state = [i, j] 82 | if str(state) in q_table.keys(): 83 | temp = q_table[str(state)][action] 84 | self.text_value(j, i, round(temp, 2), action) 85 | 86 | def coords_to_state(self, coords): 87 | x = int((coords[0] - 50) / 100) 88 | y = int((coords[1] - 50) / 100) 89 | return [x, y] 90 | 91 | def state_to_coords(self, state): 92 | x = int(state[0] * 100 + 50) 93 | y = int(state[1] * 100 + 50) 94 | return [x, y] 95 | 96 | def reset(self): 97 | self.update() 98 | time.sleep(0.5) 99 | x, y = self.canvas.coords(self.rectangle) 100 | self.canvas.move(self.rectangle, UNIT / 2 - x, UNIT / 2 - y) 101 | self.render() 102 | return self.coords_to_state(self.canvas.coords(self.rectangle)) 103 | 104 | def step(self, action): 105 | state = self.canvas.coords(self.rectangle) 106 | base_action = np.array([0, 0]) 107 | self.render() 108 | 109 | if action == 0: # 상 110 | if state[1] > UNIT: 111 | base_action[1] -= UNIT 112 | elif action == 1: # 하 113 | if state[1] < (HEIGHT - 1) * UNIT: 114 | base_action[1] += UNIT 115 | elif action == 2: # 좌 116 | if state[0] > UNIT: 117 | base_action[0] -= UNIT 118 | elif action == 3: # 우 119 | if state[0] < (WIDTH - 1) * UNIT: 120 | base_action[0] += UNIT 121 | 122 | # 에이전트 이동 123 | self.canvas.move(self.rectangle, base_action[0], base_action[1]) 124 | # 에이전트(빨간 네모)를 가장 상위로 배치 125 | self.canvas.tag_raise(self.rectangle) 126 | next_state = self.canvas.coords(self.rectangle) 127 | 128 | # 보상 함수 129 | if next_state == self.canvas.coords(self.circle): 130 | reward = 100 131 | done = True 132 | elif next_state in [self.canvas.coords(self.triangle1), 133 | self.canvas.coords(self.triangle2)]: 134 | reward = -100 135 | done = True 136 | else: 137 | reward = 0 138 | done = False 139 | 140 | next_state = self.coords_to_state(next_state) 141 | return next_state, reward, done 142 | 143 | def render(self): 144 | time.sleep(0.03) 145 | self.update() 146 | -------------------------------------------------------------------------------- /snu_lecture/code/q-learning/q_learning_agent.py: -------------------------------------------------------------------------------- 1 | from collections import defaultdict 2 | from environment import Env 3 | import random 4 | 5 | 6 | class QLearningAgent: 7 | def __init__(self, actions): 8 | # 행동 = [0, 1, 2, 3] 순서대로 상, 하, 좌, 우 9 | self.actions = actions 10 | self.learning_rate = 0.1 11 | self.discount_factor = 0.9 12 | self.epsilon = 0.1 13 | self.q_table = defaultdict(lambda: [0.0, 0.0, 0.0, 0.0]) 14 | 15 | # 샘플로부터 큐함수 업데이트 16 | def learn(self, state, action, reward, next_state): 17 | q_1 = self.q_table[state][action] 18 | # 벨만 최적 방정식을 사용한 큐함수의 업데이트 19 | q_2 = reward + self.discount_factor * max(self.q_table[next_state]) 20 | self.q_table[state][action] += self.learning_rate * (q_2 - q_1) 21 | 22 | # 큐함수에 의거하여 입실론 탐욕 정책에 따라서 행동을 반환 23 | def get_action(self, state): 24 | if random.random() <= self.epsilon: 25 | # 무작위 행동 반환 26 | action = random.choice(self.actions) 27 | else: 28 | # 큐함수에 따른 행동 반환 29 | state_action = self.q_table[state] 30 | action = self.arg_max(state_action) 31 | return action 32 | 33 | @staticmethod 34 | def arg_max(state_action): 35 | max_index_list = [] 36 | max_value = state_action[0] 37 | for index, value in enumerate(state_action): 38 | if value > max_value: 39 | max_index_list.clear() 40 | max_value = value 41 | max_index_list.append(index) 42 | elif value == max_value: 43 | max_index_list.append(index) 44 | return random.choice(max_index_list) 45 | 46 | if __name__ == "__main__": 47 | env = Env() 48 | agent = QLearningAgent(actions=list(range(env.n_actions))) 49 | 50 | for episode in range(1000): 51 | state = env.reset() 52 | 53 | while True: 54 | env.render() 55 | 56 | # 현재 상태에 대한 행동 선택 57 | action = agent.get_action(str(state)) 58 | # 행동을 취한 후 다음 상태, 보상 에피소드의 종료여부를 받아옴 59 | next_state, reward, done = env.step(action) 60 | 61 | # 로 큐함수를 업데이트 62 | agent.learn(str(state), action, reward, str(next_state)) 63 | state = next_state 64 | # 모든 큐함수를 화면에 표시 65 | env.print_value_all(agent.q_table) 66 | 67 | if done: 68 | break 69 | -------------------------------------------------------------------------------- /snu_lecture/code/q-learning/q_learning_exercise1.py: -------------------------------------------------------------------------------- 1 | from environment import Env 2 | import random 3 | 4 | if __name__ == "__main__": 5 | env = Env() 6 | 7 | for episode in range(10): 8 | print('episode ' + str(episode) + ' ----------------') 9 | env.reset() 10 | 11 | while True: 12 | env.render() 13 | # 랜덤하게 행동을 선택 (상, 하, 좌, 우) 14 | action = random.choice([0, 1, 2, 3]) 15 | # 한 스텝 환경에서 진행 16 | state, reward, done = env.step(action) 17 | print('state: ', state, ' action: ', action, ' reward: ', reward) 18 | 19 | if done: 20 | break 21 | -------------------------------------------------------------------------------- /snu_lecture/code/q-learning/q_learning_exercise2.py: -------------------------------------------------------------------------------- 1 | from collections import defaultdict 2 | from environment import Env 3 | import random 4 | 5 | 6 | class QLearningAgent: 7 | def __init__(self, actions): 8 | # 행동 = [0, 1, 2, 3] 순서대로 상, 하, 좌, 우 9 | pass 10 | 11 | # 샘플로부터 큐함수 업데이트 12 | def learn(self, state, action, reward, next_state): 13 | pass 14 | 15 | # 큐함수에 의거하여 입실론 탐욕 정책에 따라서 행동을 반환 16 | def get_action(self, state): 17 | pass 18 | 19 | @staticmethod 20 | def arg_max(state_action): 21 | max_index_list = [] 22 | max_value = state_action[0] 23 | for index, value in enumerate(state_action): 24 | if value > max_value: 25 | max_index_list.clear() 26 | max_value = value 27 | max_index_list.append(index) 28 | elif value == max_value: 29 | max_index_list.append(index) 30 | return random.choice(max_index_list) 31 | 32 | if __name__ == "__main__": 33 | env = Env() 34 | agent = QLearningAgent(actions=list(range(env.n_actions))) 35 | 36 | for episode in range(1000): 37 | state = env.reset() 38 | 39 | while True: 40 | env.render() 41 | 42 | # 현재 상태에 대한 행동 선택 43 | 44 | # 행동을 취한 후 다음 상태, 보상 에피소드의 종료여부를 받아옴 45 | 46 | # 로 큐함수를 업데이트 47 | 48 | # 모든 큐함수를 화면에 표시 49 | env.print_value_all(agent.q_table) 50 | 51 | if done: 52 | break 53 | -------------------------------------------------------------------------------- /snu_lecture/install_guide/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/.DS_Store -------------------------------------------------------------------------------- /snu_lecture/install_guide/README.md: -------------------------------------------------------------------------------- 1 | # Installation guide 2 | 3 | 강화학습 튜토리얼의 환경 설치 설명을 위한 레포지토리 입니다. 4 | 5 | 다음 세가지의 설치 환경을 설명합니다. 6 | 7 | 해당 링크를 누르면 환경 설치에 대한 상세 가이드를 보실 수 있습니다. 8 | 9 | - **윈도우 [[link]](./윈도우10_설치가이드.md)** 10 | 11 | - **리눅스(우분투) [[link]](./우분투_설치가이드.md)** 12 | 13 | - **맥(osx) [[link]](./맥_설치가이드.md)** 14 | 15 | ​ 16 | 17 | ### IDE(interface Development environment) 18 | 19 | 공통적으로 파이참(pycharm)[[link]](https://www.jetbrains.com/pycharm/)을 IDE로 사용하고 있습니다. 20 | 21 | 22 | 23 | ### 파이썬 패키지 관리자(package manager) 24 | 25 | - 윈도우, 리눅스(우분투)와 맥(osx) 모두 pip를 사용합니다. 26 | 27 | 파이썬을 설치하면 내장으로 설치되어 있습니다. 28 | -------------------------------------------------------------------------------- /snu_lecture/install_guide/img/how-to-windows.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/img/how-to-windows.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/img/link-env-with-pychar-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/img/link-env-with-pychar-1.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/img/link-env-with-pychar-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/img/link-env-with-pychar-2.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/img/link-env-with-pychar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/img/link-env-with-pychar.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/img/numpy_install.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/img/numpy_install.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/img/numpy_install2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/img/numpy_install2.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/img/numpy_install3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/img/numpy_install3.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/img/python3png.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/img/python3png.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/img/python_install.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/img/python_install.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/img/win_atari.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/img/win_atari.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/img/win_atari.py3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/img/win_atari.py3.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/img/win_breakout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/img/win_breakout.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/img/win_breakout2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/img/win_breakout2.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/img/win_git.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/img/win_git.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/img/win_git2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/img/win_git2.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/img/win_gym.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/img/win_gym.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/img/win_make.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/img/win_make.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/img/win_make2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/img/win_make2.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/img/win_msys2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/img/win_msys2.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/img/win_msys2_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/img/win_msys2_2.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/img/win_msys2_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/img/win_msys2_3.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/img/win_msys2_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/img/win_msys2_4.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/img/win_msys2_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/img/win_msys2_5.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/img/win_openai_gym.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/img/win_openai_gym.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/img/win_openai_gym2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/img/win_openai_gym2.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/img/win_openai_gym3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/img/win_openai_gym3.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/img/win_openai_gym4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/img/win_openai_gym4.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/img/win_openai_gym5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/img/win_openai_gym5.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/img/win_pycharm_install1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/img/win_pycharm_install1.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/img/win_pycharm_project.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/img/win_pycharm_project.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/img/win_pycharm_project2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/img/win_pycharm_project2.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/img/win_pycharm_setting2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/img/win_pycharm_setting2.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/img/win_pycharm_settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/img/win_pycharm_settings.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/img/win_setting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/img/win_setting.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/img/win_setting2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/img/win_setting2.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/img/win_setting3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/img/win_setting3.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/img/win_setting4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/img/win_setting4.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/img/win_setup.py.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/img/win_setup.py.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/img/win_setup.py2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/img/win_setup.py2.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/img/win_xming.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/img/win_xming.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/install_image/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/install_image/.DS_Store -------------------------------------------------------------------------------- /snu_lecture/install_guide/install_image/atari_breakout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/install_image/atari_breakout.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/install_image/cartpole_exam.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/install_image/cartpole_exam.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/install_image/console_hello_world.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/install_image/console_hello_world.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/install_image/deep_sarsa.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/install_image/deep_sarsa.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/install_image/deep_sarsa_run.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/install_image/deep_sarsa_run.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/install_image/deep_sarsa_run2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/install_image/deep_sarsa_run2.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/install_image/default_config.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/install_image/default_config.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/install_image/file_setting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/install_image/file_setting.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/install_image/hello_world_ubuntu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/install_image/hello_world_ubuntu.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/install_image/install_keras.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/install_image/install_keras.PNG -------------------------------------------------------------------------------- /snu_lecture/install_guide/install_image/install_matplotlib.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/install_image/install_matplotlib.PNG -------------------------------------------------------------------------------- /snu_lecture/install_guide/install_image/install_numpy.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/install_image/install_numpy.PNG -------------------------------------------------------------------------------- /snu_lecture/install_guide/install_image/install_pillow.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/install_image/install_pillow.PNG -------------------------------------------------------------------------------- /snu_lecture/install_guide/install_image/install_tensorflow.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/install_image/install_tensorflow.PNG -------------------------------------------------------------------------------- /snu_lecture/install_guide/install_image/openai_github.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/install_image/openai_github.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/install_image/project_interpreter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/install_image/project_interpreter.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/install_image/pycham_new_project.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/install_image/pycham_new_project.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/install_image/pycharm_community.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/install_image/pycharm_community.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/install_image/pycharm_drag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/install_image/pycharm_drag.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/install_image/pycharm_init.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/install_image/pycharm_init.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/install_image/python3_terminal.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/install_image/python3_terminal.jpg -------------------------------------------------------------------------------- /snu_lecture/install_guide/install_image/python_download.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/install_image/python_download.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/install_image/python_installed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/install_image/python_installed.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/install_image/python_intalled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/install_image/python_intalled.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/install_image/q_learning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/install_image/q_learning.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/install_image/q_learning_run.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/install_image/q_learning_run.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/install_image/rl_book_hello_world.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/install_image/rl_book_hello_world.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/install_image/rl_book_project.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/install_image/rl_book_project.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/install_image/rl_book_venv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/install_image/rl_book_venv.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/install_image/rl_book_virtualenv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/install_image/rl_book_virtualenv.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/install_image/rlcode_book_directory.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/install_image/rlcode_book_directory.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/install_image/rlcode_project.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/install_image/rlcode_project.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/install_image/run_hello_world.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/install_image/run_hello_world.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/install_image/sh_pycharm.sh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/install_image/sh_pycharm.sh.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/install_image/terminal_rlcode_book.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/install_guide/install_image/terminal_rlcode_book.png -------------------------------------------------------------------------------- /snu_lecture/install_guide/맥_설치가이드.md: -------------------------------------------------------------------------------- 1 | ## 개발 환경 설정 : 맥 OS 2 | 3 | 맥 OS에는 기본적으로 파이썬 2.7버전이 설치되어있기 때문에 3.5 버전을 새로 설치를 해야 합니다. 4 | 5 | ### 1. 파이썬 3.5 설치 및 환경 설정 6 | 7 | 파이썬 다운로드 페이지[[Link]](https://www.python.org/downloads/release/python-350/)로 접속하면 다음과 같은 화면이 나옵니다. 8 | 9 |

10 | 11 | 12 | 13 | 1. 위 화면에서 자신의 맥 OS 버전에 맞는 파일을 선택해서 다운로드합니다. 다운로드가 완료된 파일을 실행 후 안내에 따르면 설치가 완료됩니다. 14 | 15 | ​ 16 | 17 |

18 | 19 | 0383 20 | 21 | ​ 22 | 23 | 2. 파이썬 설치가 정상적으로 완료됐는지 확인하기 위해서는 터미널을 실행합니다. 터미널 창에 ‘python3’ 명령어를 입력했을 때 다음 화면과 같이 출력된다면 정상적으로 설치된 것입니다. 24 | 25 | ​ 26 | 27 |

28 | 29 | ​ 30 | 31 | ### 2. 파이참 커뮤니티 설치 및 환경 설정 32 | 33 | 파이참의 설치 및 환경 설정은 다음과 같은 순서로 진행합니다. 34 | 35 | 1. 파이참 홈페이지[[Link]](https://www.jetbrains.com/pycharm/)에 접속하여 커뮤니티버전을 다운로드합니다. 36 | 37 | 2. 다운로드가 완료된 파일을 실행하고아래 그림에서 왼쪽 PyCharm CE 아이콘을 오른쪽 폴더 아이콘으로 드래그하면 설치가 완료됩니다. 38 | 39 |

40 | 41 | 3. 처음 파이참을 실행하게 되면 설정화면이 나오는데 IDE theme을 통해 IDE의 색상과 스타일을 변경할 수 있습니다. Default는 우분투의 개발환경설정에서 봤던 Intellij 테마입니다. 이 책에서는 Default를 사용할 것입니다. 42 | ​ 43 | 44 | 4. 초기 설정을 완료하고 Create New Project 버튼을 클릭합니다. 45 | 46 | ​ 47 | 48 | 5. Create New Project 버튼을 클릭하면 아래 그림과 같은 화면이 나옵니다. Location은 프로젝트가 생성될 경로와 프로젝트 폴더명을 설정하는 곳입니다. 프로젝트의 이름과 경로는 독자가 임의로 지정하면 됩니다. 49 | 50 | Interpreter는 프로젝트에서 어떤 파이썬 Interpreter를 사용할 것인지 고르는 것입니다. 우분투에서와 마찬가지로 VirtualEnv를 통해 가상 환경을 만들고 그것을 Interpreter로 사용할 것입니다. Create VirtualEnv 버튼을 누릅니다. 51 | 52 | ​ 53 | 54 |

55 | 56 | ​ 57 | 58 | 6. 아래 그림은 VirtualEnv의 생성화면입니다. Name과 Location은 여러분이 임의로 설정하면 됩니다. Base Interpreter는 위와 같이 새로 설치한 python3.5 를 선택합니다. OK버튼을 누르면 해당 VirtualEnv가 생성됩니다. 59 | 60 | ​ 61 | 62 |

63 | 64 | ​ 65 | 66 | 7. 처음 New Project 생성화면의 Interpreter에서 방금 생성한 VirtualEnv를 선택해줍니다. 그리고 Create버튼을 누르면 프로젝트 생성이 완료됩니다. 67 | 68 | ​ 69 | 70 |

71 | 72 | ​ 73 | 74 | 8. 프로젝트를 생성하고 나면 다음과 같은 작업 환경이 보입니다. 이 화면에서 최상위 폴더를 우클릭한 후 75 | 76 | New -> Python File을 클릭하면 새로운 파이썬 파일을 생성할 수 있습니다. 77 | 78 | ​ 79 | 80 |

81 | 82 | ​ 83 | 84 | 9. 파이참이 제대로 설치됐는지 확인하기 위해 hello world 예제를 실행해봅니다. 우분투에서와 동일하기 때문에 생략하겠습니다. 85 | 86 | 87 | 88 | 89 | ## Git 설치 90 | 91 | 혹시, 우분투에 Git설치가 안되신 분은 강의자료 다운로드를 위해 Git 설치를 권장합니다. 92 | 93 | 터미널에서 다음 명령어로 Git을 설치 할 수 있습니다. 94 | 95 | ```shell 96 | $ sudo apt-get install git 97 | ``` 98 | 99 | 100 | 101 | ## 튜토리얼 예제 코드 및 발표자료 다운로드 102 | 103 | Github 레포지토리에 튜토리얼 코드 및 발표자료가 업로드 되어있습니다. 104 | 105 | Git을 이용해서 다운로드 할 수 있습니다. 106 | 107 | 다운로드를 원하는 디렉토리로 이동 후 다음 명령어를 이용해 다운로드 할 수 있습니다. 108 | 109 | ```shell 110 | $ git clone https://github.com/rlcode/rlcode-tutorial.git 111 | ``` 112 | 113 | 114 | ## Numpy, Pillow 설치 115 | 116 | 그리드 월드 예제를 실행하기 위해 다음 패키지를 설치해야 합니다. 117 | 118 | 터미널에서 다음 명령어를 실행하여 설치합니다. 119 | 120 | - Numpy 설치 121 | 122 | ```shell 123 | $ pip install numpy 124 | ``` 125 | 126 | - Pillow 설치 127 | 128 | ```shell 129 | $ pip install pillow 130 | ``` 131 | 132 | 133 | 134 | ## 큐러닝(Q-Learning) 실행 135 | 136 | 그리드월드 예제로 큐러닝을 실행합니다. 137 | 138 | 파이참에서 오른쪽 클릭 후 Run을 클릭해서 실행합니다. 139 | 140 |

141 | 142 | 혹은, 터미널에서 해당 디렉토리에서 명령어를 통해 실행할 수 있습니다. 143 | 144 | ```shell 145 | $ python q_learning_agent.py 146 | ``` 147 | 148 | 큐러닝 실행화면 입니다. 149 | 150 |

151 | 152 | 153 | 154 | ## Tensorflow, Keras, Matplotlib, h5py 설치 155 | 156 | 딥살사(deep-SARSA)를 실행하기 위해 다음 라이브러리들을 설치해야합니다. 157 | 158 | 터미널에서 다음 명령어를 실행하여 설치합니다. 159 | 160 | - **tensorflow** : 딥러닝 오픈소스 프레임워크 161 | - **Keras** : tensorflow wrapper모듈(이 튜토리얼에서 Keras는 tensorflow를 backend로 사용합니다.) 162 | - **Matplotlib** : 파이썬 2-D plotting 라이브러리(에이전트의 리워드를 그래프로 시각화하기 위한 용도) 163 | - **h5py** : HDF5 바이너리 데이터 포맷의 형식을 저장하고 불러 올 수 있게하는 파이썬 라이브러리 입니다 164 | ​ (튜토리얼에서 학습된 에이전트 모델을 저장하고 불러오는 역할을 합니다.) 165 | 166 | 167 | ```shell 168 | # Keras 설치 169 | $ pip install keras 170 | 171 | # tensorflow 설치 172 | $ pip install tensorflow 173 | 174 | # matplotlib 설치 175 | $ pip install matplotlib 176 | 177 | # h5py 설치 178 | $ pip install h5py 179 | ``` 180 | 181 | 182 | 183 | ## 딥살사(Deep-SARSA) 실행 184 | 185 | 위의 환경설치를 완료하고 딥살사를 실행합니다. 이번 튜토리얼을 정상적으로 진행하기 위해 딥살사가 실행되어야 합니다. 186 | 187 | 파이참에서 오른쪽 클릭 후 Run을 클릭해서 실행합니다. 188 | 189 |

190 | 191 | 혹은, 터미널에서 해당 디렉토리에서 명령어를 통해 실행할 수 있습니다. 192 | 193 | ```shell 194 | $ python deep_sarsa_agent.py 195 | ``` 196 | 197 | 딥살사 실행화면 입니다. 198 | 199 |

200 | 201 | 202 | -------------------------------------------------------------------------------- /snu_lecture/install_guide/우분투_설치가이드.md: -------------------------------------------------------------------------------- 1 | ## 개발 환경 설정 : 리눅스 (우분투) 2 | 3 | 리눅스는 소스코드가 공개된 대표적인 오픈소스 운영체제입니다. 리눅스는 모든 소스가 공개되어 있으므로 정말 많은 종류가 있습니다. 그중에서도 우분투(Ubuntu)가 가장 넓은 사용자를 가진 배포판입니다. 매년 상반기 하반기 우분투 재단에서 새로운 버전을 배포하는데 이 책에서는 14년 상반기에 배포한 우분투 14.04 버전을 사용할 것입니다. 우분투 14.04가 설치되어 있다는 가정에 따라 이후의 개발환경 설정을 설명할 것입니다. 4 | 5 | 6 | 7 | ### 1. 우분투 파이썬의 버전 확인 8 | 9 | 리눅스의 장점은 바로 파이썬(Python)이 설치가 기본적으로 되어 있다는 것입니다. 파이썬은 2.X 버전과 3.X버전이 있는데 이 책에서는 `파이썬 3.5버전`을 사용할 것입니다. 바탕화면에서 `Ctrl+Alt+t`를 누르면 터미널 창이 뜨는데 10 | 여기에 다음 명령어를 치고 엔터를 누르면 설치된 파이썬의 버전을 확인할 수 있습니다. 11 | 12 | ```shell 13 | $ python -V 14 | ``` 15 | 16 | 우분투 14.04 버전에는 `파이썬 2.7버전`과 `3.5버전`이 기본적으로 설치되어 있습니다. 17 | 18 | 19 | 20 | ### 2. 파이참 커뮤니티 설치 및 환경 설정 21 | 22 | 앞으로 강화학습 에이전트를 만들고 가상 환경에서 에이전트를 학습시킬 것입니다. 그러기 위해 코드를 짜고 편집하는 23 | 환경이 필요한데 그러한 환경을 IDE(interface Development Environment)라고 합니다. IDE에는 많은 종류가 있지만 이 책에서는 파이참(Pycharm)을 파이썬을 위한 IDE로 사용할 것입니다. 24 | 25 | 파이참의 설치는 파이참의 공식 홈페이지[[1\]](#_ftn1)를통해서 할 수 있습니다. 홈페이지에서 윈도우, 리눅스, 맥 OS 버전의 파이참을 다운로드 할 수 있습니다. 파이참은 유료 버전인 `프로페셔녈(PyCharm ProfessionalEdition)`과, 무료 버전인 `커뮤니티(PyCharm Community Edition)`으로 나뉩니다. 앞으로 에이전트를 개발할 때 `파이참 커뮤니티`를 사용할 것이므로 커뮤니티 버전을 기준으로 설치법을 설명할 것입니다. 26 | 27 | 28 | 29 | **설치는 다음과 같은 순서로 진행합니다.** 30 | 31 | 1. 파이참 공식 홈페이지[[Link]](https://www.jetbrains.com/pycharm/download/#section=linux) 링크에서 파이참 커뮤니티버전을 다운로드합니다. 32 | 33 | 34 |

35 | 36 | ​ 37 | 38 | 2. 다운받은 경로로 들어가서 다음 명령어로 압축파일을 풀어줍니다. 39 | 40 | ```shell 41 | $ tar xfz pycharm-community-2016.3.2.tar.gz 42 | ``` 43 | 44 | 45 | 46 | 47 | 3. 압축을 푼 후 아래 경로(bin폴더)로 이동합니다. 48 | 49 | ```shell 50 | $ cd ~/pycharm-community-2016.3.2/bin 51 | ``` 52 | ​ 53 | 54 | 4. 다음 명령어로 파이참을 실행합니다. 55 | 56 | ```shell 57 | $ sh pycharm.sh 58 | ``` 59 | ​ 60 | 61 |

62 | 63 | ​ 64 | 65 | 66 | 5. 명령어가 실행되면 설치가 시작됩니다. 67 | 68 | ​ 69 | 70 | 6. 설치가 완료되면 다음 화면과 같은 초기 환경설정 화면을 볼 수 있습니다. 71 | 72 | ​ 73 | 74 |

75 | 76 | ​ 77 | 78 | IDE theme 항목에서 Intellij는 바탕이 흰색인 테마이고 Darcula 테마는 바탕이 검은색입니다. 이 79 | 책에서는 Intellij를 테마로 사용합니다. 80 | 81 | ​ 82 | 83 | 7. 초기설정이 완료된 후의 화면입니다. 여기서 프로젝트 생성을 해봅니다. 84 | 85 |

86 | 87 | ​ 88 | 89 | ​ 90 | 91 | 8. 프로젝트의 경로와 Interpreter를 설정하는 화면입니다. Home 디렉터리에 PycharmProjects 폴더를 생성하고 그 하위에 프로젝트를 생성합니다. 프로젝트의 이름은 독자가 임의로 정하도록 합니다. “rlcode_book” 이름으로 프로젝트를 생성하는데 Interpreter를 설정해줍니다. Interpreter는 이 프로젝트에서 사용할 언어인데 python 3.5라고 설정합니다. 92 | 93 | ​ 94 | 95 |

96 | ​ 97 | 98 | 9. rlcode_book 프로젝트가 생성되면 아래와 같은 화면이 나옵니다. 99 | 100 | ​ 101 | 102 |

103 | 104 | ​ 105 | 106 | ​ 107 | 108 | 10. 파이참이 정상적으로 설치되었는지 확인하기 위해 파이썬 스크립트 파일을 생성해봅니다. 가장 간단한 예제인 `“Hello World”`를 실행하기 위해 다음과 같이 hello_world.py 파일을 생성합니다. 109 | ​ 110 | 111 |

112 | ​ 113 | 114 | 11. 생성한 파일에 마우스 커서를 놓고 오른쪽 버튼을 누르면 여러 항목이 나옵니다. 그 중에서 “Run ‘hello_world’” 버튼을 누르면 hello_world.py 파일을 실행할 수 있습니다. 115 | ​ 116 | 117 |

118 | 119 | 120 | 121 | 12. hello_world.py 파일 안에 다음 코드를 입력합니다. 122 | ```python 123 | print("hello world") 124 | ``` 125 | 126 | 127 | 128 | 129 | 13. hello_world.py 파일을 실행시키면 아래 화면과 같이 실행 창에 “hello world”가 나옵니다. 이를 통해 파이참이 정상적으로 설치된 것을 확인할 수 있습니다. 130 | 131 | ​ 132 | 133 |

134 | 135 | 136 | ## Git 설치 137 | 138 | 혹시, 우분투에 Git설치가 안되신 분은 강의자료 다운로드를 위해 Git 설치를 권장합니다. 139 | 140 | ```shell 141 | $ sudo apt-get install git 142 | ``` 143 | 144 | 145 | 146 | ## 튜토리얼 예제 코드 및 발표자료 다운로드 147 | 148 | Github 레포지토리에 튜토리얼 코드 및 발표자료가 업로드 되어있습니다. 149 | 150 | Git을 이용해서 다운로드 할 수 있습니다. 151 | 152 | 다운로드를 원하는 디렉토리로 이동 후 다음 명령어를 이용해 다운로드 할 수 있습니다. 153 | 154 | ```shell 155 | $ git clone https://github.com/rlcode/rlcode-tutorial.git 156 | ``` 157 | 158 | 159 | ## Numpy, Pillow 설치 160 | 161 | 그리드 월드 예제를 실행하기 위해 다음 패키지를 설치해야 합니다. 162 | 163 | 터미널에서 다음 명령어를 실행하여 설치합니다. 164 | 165 | - **Pillow** : 파이썬 이미지 라이브러리 입니다. 166 | 167 | 168 | 명령어 프롬프트(cmd)창에서 다음 명령어를 실행하여 설치합니다. 169 | 170 | ```shell 171 | $ pip install Pillow 172 | ``` 173 | 174 | 175 | 176 | - **Numpy** : 파이썬 177 | 178 | Numpy도 pillow와 같이 명령어 프롬프트창(cmd)에서 다음 명령어로 설치합니다. 179 | 180 | ```shell 181 | $ pip install numpy 182 | ``` 183 | 184 |

185 | 186 | 187 | 188 | 189 | ## 큐러닝(Q-Learning) 실행 190 | 191 | 그리드월드 예제로 큐러닝을 실행합니다. 192 | 193 | 파이참에서 오른쪽 클릭 후 Run을 클릭해서 실행합니다. 194 | 195 |

196 | 197 | 혹은, 터미널에서 해당 디렉토리에서 명령어를 통해 실행할 수 있습니다. 198 | 199 | ```shell 200 | $ python q_learning_agent.py 201 | ``` 202 | 203 | 큐러닝 실행화면 입니다. 204 | 205 |

206 | 207 | 208 | 209 | 210 | 211 | ## Tensorflow, Keras, Matplotlib, h5py 설치 212 | 213 | 딥살사(deep-SARSA)를 실행하기 위해 다음 라이브러리들을 설치해야합니다. 214 | 215 | Numpy, Pillow와 설치 방법은 같습니다. 216 | 217 | 명령어 프롬프트창(cmd)에서 다음 명령어를 실행하여 설치합니다. 218 | 219 | - **tensorflow** : 딥러닝 오픈소스 프레임워크 220 | 221 | ```shell 222 | $ pip install tensorflow 223 | ``` 224 | 225 | - **Keras** : tensorflow wrapper모듈(이 튜토리얼에서 Keras는 tensorflow를 backend로 사용합니다.) 226 | 227 | ```shell 228 | $ pip install keras 229 | ``` 230 | 231 | - **Matplotlib** : 파이썬 2-D plotting 라이브러리(에이전트의 리워드를 그래프로 시각화하기 위한 용도) 232 | 233 | ```shell 234 | $ pip install matplotlib 235 | ``` 236 | 237 | ​ 238 | - **h5py** : HDF5 바이너리 데이터 포맷의 형식을 저장하고 불러 올 수 있게하는 파이썬 라이브러리 입니다 239 | ​ (튜토리얼에서 학습된 에이전트 모델을 저장하고 불러오는 역할을 합니다.) 240 | 241 | ```shell 242 | $ pip install h5py 243 | ``` 244 | 245 | 246 | 247 | 248 | ## 딥살사(Deep-SARSA) 실행 249 | 250 | 위의 환경설치를 완료하고 딥살사를 실행합니다. 이번 튜토리얼을 정상적으로 진행하기 위해 딥살사가 실행되어야 합니다. 251 | 252 | 파이참에서 오른쪽 클릭 후 Run을 클릭해서 실행합니다. 253 | 254 |

255 | 256 | 또는, 터미널에서 해당 디렉토리에서 명령어를 통해 실행할 수 있습니다. 257 | 258 | ```shell 259 | $ python deep_sarsa_agent.py 260 | ``` 261 | 262 | 딥살사 실행화면 입니다. 263 | 264 |

265 | -------------------------------------------------------------------------------- /snu_lecture/install_guide/윈도우10_설치가이드.md: -------------------------------------------------------------------------------- 1 | ## 3. 윈도우 설치(윈도우 10 권장) 2 | 3 | ### 1. 파이썬 설치 4 | 5 | - 파이썬은 공식 홈페이지[[link]](https://www.python.org/downloads/windows/)에서 다운로드 할 수 있습니다. 3.5버전의 64bit 설치를 권장합니다. 6 | 7 | 8 | 9 | - 파이썬 인스톨러 실행 화면입니다. 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | ### 2. Numpy, spicy 설치 18 | 19 | - Numpy, scipy는 바이너리 파일을 다운로드하여 pip (파이썬 패키지 관리자)를 이용해 설치합니다. 바이너리 파일은 다음 링크에서 다운로드 할 수 있습니다. 20 | 21 | 링크 : [http://www.lfd.uci.edu/~gohlke/pythonlibs/](http://www.lfd.uci.edu/~gohlke/pythonlibs/) 22 | 23 | 24 | 25 | - 바이너리 파일(확장자 whl)을 윈도우 명령어창(cmd)에서 pip를 통해 설치합니다. 26 | 27 | 28 | 29 | 30 | 31 | ### 3. 파이참 설치 32 | 33 | - 파이썬을 좀 더 편리하게 사용하기 위해 IDE(interface development environment)사용을 권장합니다. 파이참은 공식 홈페이지에서 다운로드하여 설치할 수 있습니다. [[link](https://www.jetbrains.com/pycharm/download/#section=windows)] 34 | 35 | - 파이참 설치 화면 입니다. 36 | 37 | 38 | 39 | ​ 40 | 41 | - 프로젝트 생성 화면입니다. 파이참에서 기본으로 제공하는 PycharmProjects 디렉토리에 rl_book이라는 이름으로 프로젝트를 생성하겠습니다. 42 | 43 | 44 | 45 | ​ 46 | 47 | - rl_book 프로젝트가 생성되었습니다. 48 | 49 | 50 | 51 | ​ 52 | 53 | - <옵션 설정> 54 | 55 | settings에서 파이참의 다양한 설정을 할 수 있습니다. 56 | 57 | 현재 파이참 테마는 Darcula로 설정되어있습니다. 사용자에 따라 원하는 테마를 설정할 수 있습니다. 58 | 59 | 60 | 61 | ​ 62 | 63 | - Setting 왼쪽의 Project : rl_book(프로젝트 명)을 클릭하면 현재 프로젝트의 파이썬 버전과 인터프리터를 설정할 수 있습니다. virtualenv(가상환경)을 생성할 수 있고 현재 프로젝트에 설치된 파이썬 패키지들의 버전들을 확인 할 수 있습니다. 64 | 65 | 66 | 67 | 68 | 69 | ### 4. Git 설치 70 | 71 | - 튜토리얼 자료가 Github[[Link]](https://github.com/rlcode/rlcode-tutorial)에 공개되어 있습니다. 자료를 다운받기 위해 Git을 설치해야 합니다. 72 | - 링크 : https://git-scm.com/download 73 | 74 | 75 | 76 | ​ 77 | 78 | - Git 설치 화면입니다. Git 설치가 완료되면 뒤에서 설치할 Openai gym과 atari.py등을 다운로드 할 수 있습니다. 79 | 80 | 81 | 82 | 83 | 84 | 85 | ## 튜토리얼 예제 코드 및 발표자료 다운로드 86 | 87 | Github 레포지토리에 튜토리얼 코드 및 발표자료가 업로드 되어있습니다. 88 | 89 | Git을 이용해서 다운로드 할 수 있습니다. 90 | 91 | 다운로드를 원하는 디렉토리로 이동 후 다음 명령어를 이용해 다운로드 할 수 있습니다. 92 | 93 | ```shell 94 | $ git clone https://github.com/rlcode/rlcode-tutorial.git 95 | ``` 96 | 97 | 98 | 99 | ## 5. Numpy, Pillow 설치 100 | 101 | 그리드 월드 예제를 실행하기 위해 다음 패키지를 설치해야 합니다. 102 | 103 | 터미널에서 다음 명령어를 실행하여 설치합니다. 104 | 105 | - **Pillow** : 파이썬 이미지 라이브러리 입니다. 106 | 107 | 명령어 프롬프트(cmd)창에서 다음 명령어를 실행하여 설치합니다. 108 | 109 | ```shell 110 | $ pip install Pillow 111 | ``` 112 | 113 |

114 | 115 | 116 | 117 | 118 | 119 | - **Numpy** : 파이썬 120 | 121 | Numpy도 pillow와 같이 명령어 프롬프트창(cmd)에서 다음 명령어로 설치합니다. 122 | 123 | ```shell 124 | $ pip install numpy 125 | ``` 126 | 127 |

128 | 129 | 130 | 131 | 132 | ## 큐러닝(Q-Learning) 실행 133 | 134 | 그리드월드 예제로 큐러닝을 실행합니다. 135 | 136 | 파이참에서 오른쪽 클릭 후 Run을 클릭해서 실행합니다. 137 | 138 |

139 | 140 | 혹은, 터미널에서 해당 디렉토리에서 명령어를 통해 실행할 수 있습니다. 141 | 142 | ```shell 143 | $ python q_learning_agent.py 144 | ``` 145 | 146 | 큐러닝 실행화면 입니다. 147 | 148 |

149 | 150 | 151 | 152 | ### 6. Tensorflow, Keras, Matplotlib, h5py 설치 153 | 154 | 딥살사(deep-SARSA)를 실행하기 위해 다음 라이브러리들을 설치해야합니다. 155 | 156 | Numpy, Pillow와 설치 방법은 같습니다. 157 | 158 | 명령어 프롬프트창(cmd)에서 다음 명령어를 실행하여 설치합니다. 159 | 160 | - **tensorflow** : 딥러닝 오픈소스 프레임워크 161 | 162 | ```shell 163 | $ pip install tensorflow 164 | ``` 165 | 166 |

178 | 179 | ​ 180 | 181 | - **Matplotlib** : 파이썬 2-D plotting 라이브러리(에이전트의 리워드를 그래프로 시각화하기 위한 용도) 182 | 183 | ```shell 184 | $ pip install matplotlib 185 | ``` 186 | 187 |

188 | 189 | ​ 190 | 191 | - **h5py** : HDF5 바이너리 데이터 포맷의 형식을 저장하고 불러 올 수 있게하는 파이썬 라이브러리 입니다. 192 | ​ (튜토리얼에서 학습된 에이전트 모델을 저장하고 불러오는 역할을 합니다.) 193 | 194 | ```shell 195 | $ pip install h5py 196 | ``` 197 | 198 | ​ 199 | 200 | 201 | ### 7. 딥살사(Deep-SARSA) 실행 202 | 203 | 위의 환경설치를 완료하고 딥살사를 실행합니다. 이번 튜토리얼을 정상적으로 진행하기 위해 딥살사가 실행되어야 합니다. 204 | 205 | 파이참에서 오른쪽 클릭 후 Run을 클릭해서 실행합니다. 206 | 207 |

208 | 209 | 또는, 터미널에서 해당 디렉토리에서 명령어를 통해 실행할 수 있습니다. 210 | 211 | ```shell 212 | $ python deep_sarsa_agent.py 213 | ``` 214 | 215 | 딥살사 실행화면 입니다. 216 | 217 |

218 | 219 | -------------------------------------------------------------------------------- /snu_lecture/서울대학교 인지과학 튜토리얼.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/snu_lecture/서울대학교 인지과학 튜토리얼.pdf -------------------------------------------------------------------------------- /wiki/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/.DS_Store -------------------------------------------------------------------------------- /wiki/README.md: -------------------------------------------------------------------------------- 1 | # Installation guide 2 | 3 | 강화학습 튜토리얼의 환경 설치 설명을 위한 레포지토리 입니다. 4 | 5 | 다음 세가지의 설치 환경을 설명합니다. 6 | 7 | 해당 링크를 누르면 환경 설치에 대한 상세 가이드를 보실 수 있습니다. 8 | 9 | - **윈도우 [[link]](./윈도우10_설치가이드.md)** 10 | 11 | - **리눅스(우분투) [[link]](./우분투_설치가이드.md)** 12 | 13 | - **맥(osx) [[link]](./맥_설치가이드.md)** 14 | 15 | ​ 16 | 17 | ### IDE(interface Development environment) 18 | 19 | 공통적으로 파이참(pycharm)[[link]](https://www.jetbrains.com/pycharm/)을 IDE로 사용하고 있습니다. 20 | 21 | 22 | 23 | ### 파이썬 패키지 관리자(package manager) 24 | 25 | - 윈도우, 리눅스(우분투)와 맥(osx) 모두 pip를 사용합니다. 26 | 27 | 파이썬을 설치하면 내장으로 설치되어 있습니다. 28 | -------------------------------------------------------------------------------- /wiki/img/how-to-windows.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/img/how-to-windows.png -------------------------------------------------------------------------------- /wiki/img/link-env-with-pychar-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/img/link-env-with-pychar-1.png -------------------------------------------------------------------------------- /wiki/img/link-env-with-pychar-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/img/link-env-with-pychar-2.png -------------------------------------------------------------------------------- /wiki/img/link-env-with-pychar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/img/link-env-with-pychar.png -------------------------------------------------------------------------------- /wiki/img/numpy_install.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/img/numpy_install.png -------------------------------------------------------------------------------- /wiki/img/numpy_install2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/img/numpy_install2.png -------------------------------------------------------------------------------- /wiki/img/numpy_install3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/img/numpy_install3.png -------------------------------------------------------------------------------- /wiki/img/python3png.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/img/python3png.png -------------------------------------------------------------------------------- /wiki/img/python_install.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/img/python_install.png -------------------------------------------------------------------------------- /wiki/img/win_atari.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/img/win_atari.png -------------------------------------------------------------------------------- /wiki/img/win_atari.py3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/img/win_atari.py3.png -------------------------------------------------------------------------------- /wiki/img/win_breakout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/img/win_breakout.png -------------------------------------------------------------------------------- /wiki/img/win_breakout2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/img/win_breakout2.png -------------------------------------------------------------------------------- /wiki/img/win_git.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/img/win_git.png -------------------------------------------------------------------------------- /wiki/img/win_git2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/img/win_git2.png -------------------------------------------------------------------------------- /wiki/img/win_gym.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/img/win_gym.png -------------------------------------------------------------------------------- /wiki/img/win_make.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/img/win_make.png -------------------------------------------------------------------------------- /wiki/img/win_make2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/img/win_make2.png -------------------------------------------------------------------------------- /wiki/img/win_msys2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/img/win_msys2.png -------------------------------------------------------------------------------- /wiki/img/win_msys2_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/img/win_msys2_2.png -------------------------------------------------------------------------------- /wiki/img/win_msys2_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/img/win_msys2_3.png -------------------------------------------------------------------------------- /wiki/img/win_msys2_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/img/win_msys2_4.png -------------------------------------------------------------------------------- /wiki/img/win_msys2_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/img/win_msys2_5.png -------------------------------------------------------------------------------- /wiki/img/win_openai_gym.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/img/win_openai_gym.png -------------------------------------------------------------------------------- /wiki/img/win_openai_gym2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/img/win_openai_gym2.png -------------------------------------------------------------------------------- /wiki/img/win_openai_gym3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/img/win_openai_gym3.png -------------------------------------------------------------------------------- /wiki/img/win_openai_gym4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/img/win_openai_gym4.png -------------------------------------------------------------------------------- /wiki/img/win_openai_gym5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/img/win_openai_gym5.png -------------------------------------------------------------------------------- /wiki/img/win_pycharm_install1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/img/win_pycharm_install1.png -------------------------------------------------------------------------------- /wiki/img/win_pycharm_project.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/img/win_pycharm_project.png -------------------------------------------------------------------------------- /wiki/img/win_pycharm_project2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/img/win_pycharm_project2.png -------------------------------------------------------------------------------- /wiki/img/win_pycharm_setting2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/img/win_pycharm_setting2.png -------------------------------------------------------------------------------- /wiki/img/win_pycharm_settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/img/win_pycharm_settings.png -------------------------------------------------------------------------------- /wiki/img/win_setting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/img/win_setting.png -------------------------------------------------------------------------------- /wiki/img/win_setting2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/img/win_setting2.png -------------------------------------------------------------------------------- /wiki/img/win_setting3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/img/win_setting3.png -------------------------------------------------------------------------------- /wiki/img/win_setting4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/img/win_setting4.png -------------------------------------------------------------------------------- /wiki/img/win_setup.py.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/img/win_setup.py.png -------------------------------------------------------------------------------- /wiki/img/win_setup.py2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/img/win_setup.py2.png -------------------------------------------------------------------------------- /wiki/img/win_xming.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/img/win_xming.png -------------------------------------------------------------------------------- /wiki/install_image/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/install_image/.DS_Store -------------------------------------------------------------------------------- /wiki/install_image/atari_breakout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/install_image/atari_breakout.png -------------------------------------------------------------------------------- /wiki/install_image/cartpole_exam.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/install_image/cartpole_exam.png -------------------------------------------------------------------------------- /wiki/install_image/console_hello_world.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/install_image/console_hello_world.png -------------------------------------------------------------------------------- /wiki/install_image/deep_sarsa_run.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/install_image/deep_sarsa_run.png -------------------------------------------------------------------------------- /wiki/install_image/deep_sarsa_run2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/install_image/deep_sarsa_run2.png -------------------------------------------------------------------------------- /wiki/install_image/default_config.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/install_image/default_config.png -------------------------------------------------------------------------------- /wiki/install_image/file_setting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/install_image/file_setting.png -------------------------------------------------------------------------------- /wiki/install_image/hello_world_ubuntu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/install_image/hello_world_ubuntu.png -------------------------------------------------------------------------------- /wiki/install_image/install_keras.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/install_image/install_keras.PNG -------------------------------------------------------------------------------- /wiki/install_image/install_matplotlib.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/install_image/install_matplotlib.PNG -------------------------------------------------------------------------------- /wiki/install_image/install_numpy.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/install_image/install_numpy.PNG -------------------------------------------------------------------------------- /wiki/install_image/install_pillow.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/install_image/install_pillow.PNG -------------------------------------------------------------------------------- /wiki/install_image/install_tensorflow.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/install_image/install_tensorflow.PNG -------------------------------------------------------------------------------- /wiki/install_image/openai_github.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/install_image/openai_github.png -------------------------------------------------------------------------------- /wiki/install_image/project_interpreter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/install_image/project_interpreter.png -------------------------------------------------------------------------------- /wiki/install_image/pycham_new_project.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/install_image/pycham_new_project.png -------------------------------------------------------------------------------- /wiki/install_image/pycharm_community.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/install_image/pycharm_community.png -------------------------------------------------------------------------------- /wiki/install_image/pycharm_drag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/install_image/pycharm_drag.png -------------------------------------------------------------------------------- /wiki/install_image/pycharm_init.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/install_image/pycharm_init.png -------------------------------------------------------------------------------- /wiki/install_image/python3_terminal.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/install_image/python3_terminal.jpg -------------------------------------------------------------------------------- /wiki/install_image/python_download.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/install_image/python_download.png -------------------------------------------------------------------------------- /wiki/install_image/python_installed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/install_image/python_installed.png -------------------------------------------------------------------------------- /wiki/install_image/python_intalled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/install_image/python_intalled.png -------------------------------------------------------------------------------- /wiki/install_image/rl_book_hello_world.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/install_image/rl_book_hello_world.png -------------------------------------------------------------------------------- /wiki/install_image/rl_book_project.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/install_image/rl_book_project.png -------------------------------------------------------------------------------- /wiki/install_image/rl_book_venv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/install_image/rl_book_venv.png -------------------------------------------------------------------------------- /wiki/install_image/rl_book_virtualenv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/install_image/rl_book_virtualenv.png -------------------------------------------------------------------------------- /wiki/install_image/rlcode_book_directory.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/install_image/rlcode_book_directory.png -------------------------------------------------------------------------------- /wiki/install_image/rlcode_project.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/install_image/rlcode_project.png -------------------------------------------------------------------------------- /wiki/install_image/run_hello_world.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/install_image/run_hello_world.png -------------------------------------------------------------------------------- /wiki/install_image/sh_pycharm.sh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/install_image/sh_pycharm.sh.png -------------------------------------------------------------------------------- /wiki/install_image/terminal_rlcode_book.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rlcode/rlcode-tutorial/046302625aad1fc83fd5e530bc9d79454de9162e/wiki/install_image/terminal_rlcode_book.png -------------------------------------------------------------------------------- /wiki/맥_설치가이드.md: -------------------------------------------------------------------------------- 1 | ## 개발 환경 설정 2: 맥 OS 2 | 3 | 맥 OS에는 기본적으로 파이썬 2.7버전이 설치되어있기 때문에 3.5 버전을 새로 설치를 해야 합니다. 4 | 5 | ### 1.1 파이썬 3.5 설치 및 환경 설정 6 | 7 | 파이썬 다운로드 페이지[[Link]](https://www.python.org/downloads/release/python-350/)로 접속하면 다음과 같은 화면이 나옵니다. 8 | 9 |

10 | 11 | 12 | 13 | 1. 위 화면에서 자신의 맥 OS 버전에 맞는 파일을 선택해서 다운로드합니다. 다운로드가 완료된 파일을 실행 후 안내에 따르면 설치가 완료됩니다. 14 | 15 | ​ 16 | 17 |

18 | 19 | 0383 20 | 21 | ​ 22 | 23 | 2. 파이썬 설치가 정상적으로 완료됐는지 확인하기 위해서는 터미널을 실행합니다. 터미널 창에 ‘python3’ 명령어를 입력했을 때 다음 화면과 같이 출력된다면 정상적으로 설치된 것입니다. 24 | 25 | ​ 26 | 27 |

28 | 29 | ​ 30 | 31 | ### 1.2 파이참 커뮤니티 설치 및 환경 설정 32 | 33 | 파이참의 설치 및 환경 설정은 다음과 같은 순서로 진행합니다. 34 | 35 | 1. 파이참 홈페이지[[Link]](https://www.jetbrains.com/pycharm/)에 접속하여 커뮤니티버전을 다운로드합니다. 36 | 37 | 2. 다운로드가 완료된 파일을 실행하고아래 그림에서 왼쪽 PyCharm CE 아이콘을 오른쪽 폴더 아이콘으로 드래그하면 설치가 완료됩니다. 38 | 39 |

40 | 41 | 3. 처음 파이참을 실행하게 되면 설정화면이 나오는데 IDE theme을 통해 IDE의 색상과 스타일을 변경할 수 있습니다. Default는 우분투의 개발환경설정에서 봤던 Intellij 테마입니다. 이 책에서는 Default를 사용할 것입니다. 42 | ​ 43 | 44 | 4. 초기 설정을 완료하고 Create New Project 버튼을 클릭합니다. 45 | 46 | ​ 47 | 48 | 5. Create New Project 버튼을 클릭하면 아래 그림과 같은 화면이 나옵니다. Location은 프로젝트가 생성될 경로와 프로젝트 폴더명을 설정하는 곳입니다. 프로젝트의 이름과 경로는 독자가 임의로 지정하면 됩니다. 49 | 50 | Interpreter는 프로젝트에서 어떤 파이썬 Interpreter를 사용할 것인지 고르는 것입니다. 우분투에서와 마찬가지로 VirtualEnv를 통해 가상 환경을 만들고 그것을 Interpreter로 사용할 것입니다. Create VirtualEnv 버튼을 누릅니다. 51 | 52 | ​ 53 | 54 |

55 | 56 | ​ 57 | 58 | 6. 아래 그림은 VirtualEnv의 생성화면입니다. Name과 Location은 여러분이 임의로 설정하면 됩니다. Base Interpreter는 위와 같이 새로 설치한 python3.5 를 선택합니다. OK버튼을 누르면 해당 VirtualEnv가 생성됩니다. 59 | 60 | ​ 61 | 62 |

63 | 64 | ​ 65 | 66 | 7. 처음 New Project 생성화면의 Interpreter에서 방금 생성한 VirtualEnv를 선택해줍니다. 그리고 Create버튼을 누르면 프로젝트 생성이 완료됩니다. 67 | 68 | ​ 69 | 70 |

71 | 72 | ​ 73 | 74 | 8. 프로젝트를 생성하고 나면 다음과 같은 작업 환경이 보입니다. 이 화면에서 최상위 폴더를 우클릭한 후 75 | 76 | New -> Python File을 클릭하면 새로운 파이썬 파일을 생성할 수 있습니다. 77 | 78 | ​ 79 | 80 |

81 | 82 | ​ 83 | 84 | 9. 파이참이 제대로 설치됐는지 확인하기 위해 hello world 예제를 실행해봅니다. 우분투에서와 동일하기 때문에 생략하겠습니다. 85 | 86 | 87 | 88 | 89 | ## Numpy, Pillow 설치 90 | 91 | 그리드 월드 예제를 실행하기 위해 다음 패키지를 설치해야 합니다. 92 | 93 | 터미널에서 다음 명령어를 실행하여 설치합니다. 94 | 95 | - Numpy 설치 96 | 97 | ```shell 98 | $ pip install numpy 99 | ``` 100 | 101 | - Pillow 설치 102 | 103 | ```shell 104 | $ pip install pillow 105 | ``` 106 | 107 | 108 | 109 | ## Tensorflow, Keras, Matplotlib, h5py 설치 110 | 111 | 딥살사(deep-SARSA)를 실행하기 위해 다음 라이브러리들을 설치해야합니다. 112 | 113 | 터미널에서 다음 명령어를 실행하여 설치합니다. 114 | 115 | - **tensorflow** : 딥러닝 오픈소스 프레임워크 116 | - **Keras** : tensorflow wrapper모듈(이 튜토리얼에서 Keras는 tensorflow를 backend로 사용합니다.) 117 | - **Matplotlib** : 파이썬 2-D plotting 라이브러리(에이전트의 리워드를 그래프로 시각화하기 위한 용도) 118 | - **h5py** : HDF5 바이너리 데이터 포맷의 형식을 저장하고 불러 올 수 있게하는 파이썬 라이브러리 입니다 119 | ​ (튜토리얼에서 학습된 에이전트 모델을 저장하고 불러오는 역할을 합니다.) 120 | 121 | 122 | ```shell 123 | # Keras 설치 124 | $ pip install keras 125 | 126 | # tensorflow 설치 127 | $ pip install tensorflow 128 | 129 | # matplotlib 설치 130 | $ pip install matplotlib 131 | 132 | # h5py 설치 133 | $ pip install h5py 134 | ``` 135 | 136 | 137 | 138 | ## 딥살사(Deep-SARSA) 실행 139 | 140 | 위의 환경설치를 완료하고 딥살사를 실행합니다. 이번 튜토리얼을 정상적으로 진행하기 위해 딥살사가 실행되어야 합니다. 141 | 142 | 파이참에서 오른쪽 클릭 후 Run을 클릭해서 실행합니다. 143 | 144 |

145 | 146 | 혹은, 터미널에서 해당 디렉토리에서 명령어를 통해 실행할 수 있습니다. 147 | 148 | ```shell 149 | $ python deep_sarsa_agent.py 150 | ``` 151 | 152 | 딥살사 실행화면 입니다. 153 | 154 |

-------------------------------------------------------------------------------- /wiki/우분투_설치가이드.md: -------------------------------------------------------------------------------- 1 | ## 개발 환경 설정 : 리눅스 (우분투) 2 | 3 | 리눅스는 소스코드가 공개된 대표적인 오픈소스 운영체제입니다. 리눅스는 모든 소스가 공개되어 있으므로 정말 많은 종류가 있습니다. 그중에서도 우분투(Ubuntu)가 가장 넓은 사용자를 가진 배포판입니다. 매년 상반기 하반기 우분투 재단에서 새로운 버전을 배포하는데 이 책에서는 14년 상반기에 배포한 우분투 14.04 버전을 사용할 것입니다. 우분투 14.04가 설치되어 있다는 가정에 따라 이후의 개발환경 설정을 설명할 것입니다. 4 | 5 | 6 | 7 | ### 1 우분투 파이썬의 버전 확인 8 | 9 | 리눅스의 장점은 바로 파이썬(Python)이 설치가 기본적으로 되어 있다는 것입니다. 파이썬은 2.X 버전과 3.X버전이 있는데 이 책에서는 `파이썬 3.5버전`을 사용할 것입니다. 바탕화면에서 `Ctrl+Alt+t`를 누르면 터미널 창이 뜨는데 10 | 여기에 다음 명령어를 치고 엔터를 누르면 설치된 파이썬의 버전을 확인할 수 있습니다. 11 | 12 | ```shell 13 | $ python -V 14 | ``` 15 | 16 | 우분투 14.04 버전에는 `파이썬 2.7버전`과 `3.5버전`이 기본적으로 설치되어 있습니다. 17 | 18 | 19 | 20 | ### 2 파이참 커뮤니티 설치 및 환경 설정 21 | 22 | 앞으로 강화학습 에이전트를 만들고 가상 환경에서 에이전트를 학습시킬 것입니다. 그러기 위해 코드를 짜고 편집하는 23 | 환경이 필요한데 그러한 환경을 IDE(interface Development Environment)라고 합니다. IDE에는 많은 종류가 있지만 이 책에서는 파이참(Pycharm)을 파이썬을 위한 IDE로 사용할 것입니다. 24 | 25 | 파이참의 설치는 파이참의 공식 홈페이지[[1\]](#_ftn1)를통해서 할 수 있습니다. 홈페이지에서 윈도우, 리눅스, 맥 OS 버전의 파이참을 다운로드 할 수 있습니다. 파이참은 유료 버전인 `프로페셔녈(PyCharm ProfessionalEdition)`과, 무료 버전인 `커뮤니티(PyCharm Community Edition)`으로 나뉩니다. 앞으로 에이전트를 개발할 때 `파이참 커뮤니티`를 사용할 것이므로 커뮤니티 버전을 기준으로 설치법을 설명할 것입니다. 26 | 27 | 28 | 29 | **설치는 다음과 같은 순서로 진행합니다.** 30 | 31 | 1. 파이참 공식 홈페이지[[Link]](https://www.jetbrains.com/pycharm/download/#section=linux) 링크에서 파이참 커뮤니티버전을 다운로드합니다. 32 | 33 | 34 |

35 | 36 | ​ 37 | 38 | 2. 다운받은 경로로 들어가서 다음 명령어로 압축파일을 풀어줍니다. 39 | 40 | ```shell 41 | $ tar xfz pycharm-community-2016.3.2.tar.gz 42 | ``` 43 | 44 | 45 | 46 | 47 | 3. 압축을 푼 후 아래 경로(bin폴더)로 이동합니다. 48 | 49 | ```shell 50 | $ cd ~/pycharm-community-2016.3.2/bin 51 | ``` 52 | ​ 53 | 54 | 4. 다음 명령어로 파이참을 실행합니다. 55 | 56 | ```shell 57 | $ sh pycharm.sh 58 | ``` 59 | ​ 60 | 61 |

62 | 63 | ​ 64 | 65 | 66 | 5. 명령어가 실행되면 설치가 시작됩니다. 67 | 68 | ​ 69 | 70 | 6. 설치가 완료되면 다음 화면과 같은 초기 환경설정 화면을 볼 수 있습니다. 71 | 72 | ​ 73 | 74 |

75 | 76 | ​ 77 | 78 | IDE theme 항목에서 Intellij는 바탕이 흰색인 테마이고 Darcula 테마는 바탕이 검은색입니다. 이 79 | 책에서는 Intellij를 테마로 사용합니다. 80 | 81 | ​ 82 | 83 | 7. 초기설정이 완료된 후의 화면입니다. 여기서 프로젝트 생성을 해봅니다. 84 | 85 |

86 | 87 | ​ 88 | 89 | ​ 90 | 91 | 8. 프로젝트의 경로와 Interpreter를 설정하는 화면입니다. Home 디렉터리에 PycharmProjects 폴더를 생성하고 그 하위에 프로젝트를 생성합니다. 프로젝트의 이름은 독자가 임의로 정하도록 합니다. “rlcode_book” 이름으로 프로젝트를 생성하는데 Interpreter를 설정해줍니다. Interpreter는 이 프로젝트에서 사용할 언어인데 python 3.5라고 설정합니다. 92 | 93 | ​ 94 | 95 |

96 | ​ 97 | 98 | 9. rlcode_book 프로젝트가 생성되면 아래와 같은 화면이 나옵니다. 99 | 100 | ​ 101 | 102 |

103 | 104 | ​ 105 | 106 | ​ 107 | 108 | 10. 파이참이 정상적으로 설치되었는지 확인하기 위해 파이썬 스크립트 파일을 생성해봅니다. 가장 간단한 예제인 `“Hello World”`를 실행하기 위해 다음과 같이 hello_world.py 파일을 생성합니다. 109 | ​ 110 | 111 |

112 | ​ 113 | 114 | 11. 생성한 파일에 마우스 커서를 놓고 오른쪽 버튼을 누르면 여러 항목이 나옵니다. 그 중에서 “Run ‘hello_world’” 버튼을 누르면 hello_world.py 파일을 실행할 수 있습니다. 115 | ​ 116 | 117 |

118 | 119 | 120 | 121 | 12. hello_world.py 파일 안에 다음 코드를 입력합니다. 122 | ```python 123 | print("hello world") 124 | ``` 125 | 126 | 127 | 128 | 129 | 13. hello_world.py 파일을 실행시키면 아래 화면과 같이 실행 창에 “hello world”가 나옵니다. 이를 통해 파이참이 정상적으로 설치된 것을 확인할 수 있습니다. 130 | 131 | ​ 132 | 133 |

134 | 135 | ​ 136 | 137 | 138 | ## Numpy, Pillow 설치 139 | 140 | 그리드 월드 예제를 실행하기 위해 다음 패키지를 설치해야 합니다. 141 | 142 | 터미널에서 다음 명령어를 실행하여 설치합니다. 143 | 144 | - **Pillow** : 파이썬 이미지 라이브러리 입니다. 145 | 146 | 147 | 명령어 프롬프트(cmd)창에서 다음 명령어를 실행하여 설치합니다. 148 | 149 | ```shell 150 | $ pip install Pillow 151 | ``` 152 |

153 | 154 | 155 | 156 | 157 | 158 | - **Numpy** : 파이썬 159 | 160 | Numpy도 pillow와 같이 명령어 프롬프트창(cmd)에서 다음 명령어로 설치합니다. 161 | 162 | ```shell 163 | $ pip install numpy 164 | ``` 165 | 166 |

167 | 168 | 169 | 170 | 171 | ## Tensorflow, Keras, Matplotlib, h5py 설치 172 | 173 | 딥살사(deep-SARSA)를 실행하기 위해 다음 라이브러리들을 설치해야합니다. 174 | 175 | Numpy, Pillow와 설치 방법은 같습니다. 176 | 177 | 명령어 프롬프트창(cmd)에서 다음 명령어를 실행하여 설치합니다. 178 | 179 | - **tensorflow** : 딥러닝 오픈소스 프레임워크 180 | 181 | ```shell 182 | $ pip install tensorflow 183 | ``` 184 | 185 |

197 | 198 | - **Matplotlib** : 파이썬 2-D plotting 라이브러리(에이전트의 리워드를 그래프로 시각화하기 위한 용도) 199 | 200 | ```shell 201 | $ pip install matplotlib 202 | ``` 203 | 204 |

205 | 206 | ​ 207 | 208 | - **h5py** : HDF5 바이너리 데이터 포맷의 형식을 저장하고 불러 올 수 있게하는 파이썬 라이브러리 입니다 209 | ​ (튜토리얼에서 학습된 에이전트 모델을 저장하고 불러오는 역할을 합니다.) 210 | 211 | ```shell 212 | $ pip install h5py 213 | ``` 214 | 215 | 216 | 217 | 218 | ## 딥살사(Deep-SARSA) 실행 219 | 220 | 위의 환경설치를 완료하고 딥살사를 실행합니다. 이번 튜토리얼을 정상적으로 진행하기 위해 딥살사가 실행되어야 합니다. 221 | 222 | 파이참에서 오른쪽 클릭 후 Run을 클릭해서 실행합니다. 223 | 224 |

225 | 226 | 또는, 터미널에서 해당 디렉토리에서 명령어를 통해 실행할 수 있습니다. 227 | 228 | ```shell 229 | $ python deep_sarsa_agent.py 230 | ``` 231 | 232 | 딥살사 실행화면 입니다. 233 | 234 |

-------------------------------------------------------------------------------- /wiki/윈도우10_설치가이드.md: -------------------------------------------------------------------------------- 1 | ## 3. 윈도우 설치(윈도우 10 권장) 2 | 3 | ### 1. 파이썬 설치 4 | 5 | - 파이썬은 공식 홈페이지[[link]](https://www.python.org/downloads/windows/)에서 다운로드 할 수 있습니다. 3.5버전의 64bit 설치를 권장합니다. 6 | 7 | 8 | 9 | - 파이썬 인스톨러 실행 화면입니다. 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | ### 2. Numpy, spicy 설치 18 | 19 | - Numpy, scipy는 바이너리 파일을 다운로드하여 pip (파이썬 패키지 관리자)를 이용해 설치합니다. 바이너리 파일은 다음 링크에서 다운로드 할 수 있습니다. 20 | 21 | 링크 : [http://www.lfd.uci.edu/~gohlke/pythonlibs/](http://www.lfd.uci.edu/~gohlke/pythonlibs/) 22 | 23 | 24 | 25 | - 바이너리 파일(확장자 whl)을 윈도우 명령어창(cmd)에서 pip를 통해 설치합니다. 26 | 27 | 28 | 29 | 30 | 31 | ### 3. 파이참 설치 32 | 33 | - 파이썬을 좀 더 편리하게 사용하기 위해 IDE(interface development environment)사용을 권장합니다. 파이참은 공식 홈페이지에서 다운로드하여 설치할 수 있습니다. [[link](https://www.jetbrains.com/pycharm/download/#section=windows)] 34 | 35 | - 파이참 설치 화면 입니다. 36 | 37 | 38 | 39 | ​ 40 | 41 | - 프로젝트 생성 화면입니다. 파이참에서 기본으로 제공하는 PycharmProjects 디렉토리에 rl_book이라는 이름으로 프로젝트를 생성하겠습니다. 42 | 43 | 44 | 45 | ​ 46 | 47 | - rl_book 프로젝트가 생성되었습니다. 48 | 49 | 50 | 51 | ​ 52 | 53 | - <옵션 설정> 54 | 55 | settings에서 파이참의 다양한 설정을 할 수 있습니다. 56 | 57 | 현재 파이참 테마는 Darcula로 설정되어있습니다. 사용자에 따라 원하는 테마를 설정할 수 있습니다. 58 | 59 | 60 | 61 | ​ 62 | 63 | - Setting 왼쪽의 Project : rl_book(프로젝트 명)을 클릭하면 현재 프로젝트의 파이썬 버전과 인터프리터를 설정할 수 있습니다. virtualenv(가상환경)을 생성할 수 있고 현재 프로젝트에 설치된 파이썬 패키지들의 버전들을 확인 할 수 있습니다. 64 | 65 | 66 | 67 | 68 | 69 | ### 4. Git 설치 70 | 71 | - 튜토리얼 자료가 Github[[Link]](https://github.com/rlcode/rlcode-tutorial)에 공개되어 있습니다. 자료를 다운받기 위해 Git을 설치해야 합니다. 72 | - 링크 : https://git-scm.com/download 73 | 74 | 75 | 76 | ​ 77 | 78 | - Git 설치 화면입니다. Git 설치가 완료되면 뒤에서 설치할 Openai gym과 atari.py등을 다운로드 할 수 있습니다. 79 | 80 | 81 | 82 | 83 | 84 | 85 | ## 5. Numpy, Pillow 설치 86 | 87 | 그리드 월드 예제를 실행하기 위해 다음 패키지를 설치해야 합니다. 88 | 89 | 터미널에서 다음 명령어를 실행하여 설치합니다. 90 | 91 | - **Pillow** : 파이썬 이미지 라이브러리 입니다. 92 | 93 | 명령어 프롬프트(cmd)창에서 다음 명령어를 실행하여 설치합니다. 94 | 95 | ```shell 96 | $ pip install Pillow 97 | ``` 98 | 99 |

100 | 101 | 102 | 103 | 104 | 105 | - **Numpy** : 파이썬 106 | 107 | Numpy도 pillow와 같이 명령어 프롬프트창(cmd)에서 다음 명령어로 설치합니다. 108 | 109 | ```shell 110 | $ pip install numpy 111 | ``` 112 | 113 |

114 | 115 | 116 | 117 | 118 | ### 6. Tensorflow, Keras, Matplotlib, h5py 설치 119 | 120 | 딥살사(deep-SARSA)를 실행하기 위해 다음 라이브러리들을 설치해야합니다. 121 | 122 | Numpy, Pillow와 설치 방법은 같습니다. 123 | 124 | 명령어 프롬프트창(cmd)에서 다음 명령어를 실행하여 설치합니다. 125 | 126 | - **tensorflow** : 딥러닝 오픈소스 프레임워크 127 | 128 | ```shell 129 | $ pip install tensorflow 130 | ``` 131 | 132 |

144 | 145 | ​ 146 | 147 | - **Matplotlib** : 파이썬 2-D plotting 라이브러리(에이전트의 리워드를 그래프로 시각화하기 위한 용도) 148 | 149 | ```shell 150 | $ pip install matplotlib 151 | ``` 152 | 153 |

154 | 155 | ​ 156 | 157 | - **h5py** : HDF5 바이너리 데이터 포맷의 형식을 저장하고 불러 올 수 있게하는 파이썬 라이브러리 입니다. 158 | ​ (튜토리얼에서 학습된 에이전트 모델을 저장하고 불러오는 역할을 합니다.) 159 | 160 | ```shell 161 | $ pip install h5py 162 | ``` 163 | 164 | ​ 165 | 166 | 167 | ### 7. 딥살사(Deep-SARSA) 실행 168 | 169 | 위의 환경설치를 완료하고 딥살사를 실행합니다. 이번 튜토리얼을 정상적으로 진행하기 위해 딥살사가 실행되어야 합니다. 170 | 171 | 파이참에서 오른쪽 클릭 후 Run을 클릭해서 실행합니다. 172 | 173 |

174 | 175 | 또는, 터미널에서 해당 디렉토리에서 명령어를 통해 실행할 수 있습니다. 176 | 177 | ```shell 178 | $ python deep_sarsa_agent.py 179 | ``` 180 | 181 | 딥살사 실행화면 입니다. 182 | 183 |

184 | 185 | --------------------------------------------------------------------------------