We'll start by implementing the nn_agent_drive function, which allows the agent to play the game (defined in https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Python/blob/master/Chapter11/imitation_learning/nn_agent.py). The function will start the env environment with an initial state (game frame). We'll use it as an input to the network. Then, we'll convert the softmax network output from one-hot encoding to an array-based action and we'll send it to the environment to make the next step. We'll repeat these steps until the episode ends. The nn_agent_drive function also allows the user to exit by pressing Escape. Note that we still use the same data_transform transformations as we did for the training. ...
Letting the agent drive
Get Advanced Deep Learning with Python now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.