How to do it...

We proceed with the recipe as follows:

  1. The first step is importing the necessary modules. This time, besides our usual TensorFlow, Numpy, and Matplotlib, we will be importing Gym and some classes from scikit:
import numpy as npimport tensorflow as tfimport gymimport matplotlib.pyplot as pltfrom sklearn.pipeline import FeatureUnionfrom sklearn.preprocessing import StandardScalerfrom sklearn.kernel_approximation import RBFSampler
  1. In Q learning, we use NNs as function approximators to estimate the value-function. We define a linear NeuralNetwork class; the NN will take the transformed observation space as input and will predict the estimated Q value. As we have two possible actions, we need two different neural network objects ...

Get TensorFlow 1.x Deep Learning Cookbook 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.