16.03.2021 Views

Advanced Deep Learning with Keras

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Deep Reinforcement Learning

self.col = 4

# 6 states

self.row = 6

# setup the environment

self.q_table = np.zeros([self.row, self.col])

self.init_transition_table()

self.init_reward_table()

# discount factor

self.gamma = 0.9

# 90% exploration, 10% exploitation

self.epsilon = 0.9

# exploration decays by this factor every episode

self.epsilon_decay = 0.9

# in the long run, 10% exploration, 90% exploitation

self.epsilon_min = 0.1

# reset the environment

self.reset()

self.is_explore = True

# start of episode

def reset(self):

self.state = 0

return self.state

# agent wins when the goal is reached

def is_in_win_state(self):

return self.state == 2

def init_reward_table(self):

"""

0 - Left, 1 - Down, 2 - Right, 3 - Up

----------------

| 0 | 0 | 100 |

----------------

| 0 | 0 | -100 |

[ 282 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!