O'Reilly logo

Python Deep Learning Cookbook by Indra den Bakker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

  1. Let's start with importing the necessary libraries, as follows:
import gymimport randomimport numpy as npimport matplotlib.pyplot as pltfrom collections import dequefrom keras.models import Sequentialfrom keras.optimizers import Adamfrom keras.layers import Dense, Flattenfrom keras.layers.convolutional import Conv2Dfrom keras import backend as K
  1. First, we will plot an example input image of the game:
Figure 11.1: Example input image of Breakout by OpenAI
env = gym.make('BreakoutDeterministic-v4')observation = env.reset()for i in range(3):    # The ball is released after 2 frames    if i > 1:        print(observation.shape) plt.imshow(observation) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required