October 2018
Intermediate to advanced
472 pages
10h 57m
English
Let's define a function that, when called, will return the action that needs to be taken for that specific state:
def agent_action(model, epsilon, state, actions): """Define action to be taken.""" if np.random.rand() <= epsilon: act = random.randrange(actions) else: act = np.argmax(model.predict(state)[0]) return act
For any value from the uniform distribution (between 0 and 1), less than or equal to epsilon, the action returned will be random. For any value greater than epsilon, the action chosen will be that predicted by the agent we have defined in the preceding code.
Read now
Unlock full access