Testing the agent

Once the agent has been trained, we evaluate its performance over 100 new episodes. This can be done by calling the .test function and feeding the arguments environment and number of episodes on which to test.

# Evaluate the agent on 100 new episodes.
scores = sarsa.test(env, nb_episodes=100, visualize=False)

print('Average score over 100 test games: {}'.format(np.mean(scores.history['episode_reward'])))
To view the Cart-Pole game on your screen when testing, set visualize argument to true inside the .test function.
......
......
......
Figure 15.16: Test scores with trained SARSA agent
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.59.197.213