October 2018
Beginner
362 pages
9h 32m
English
Now, let's get to the moment we've been waiting for! Let's import gym, NumPy, our deep-q network file, as well as a few handler functions:
import cv2import sysfrom deepQ import deepQimport numpy as npimport gym
We'll define our agent class as Atari, and initialize the environment, network, and actions with the class:
class Atari: def __init__(self): self.env = gym.make('SpaceInvaders-v0') self.env.reset() self.actions = self.env.action_space.n self.deepQ = deepQ(self.actions) self.action0 = 0
Our Deep Q-network can't innately ingest the Atari games, so we have to write a bit of preprocessing code to handle the video input. We'll call this function preprocess and it will take in a single game observation:
def preprocess(self,observation): ...
Read now
Unlock full access