Simple linear regression example

To better digest all the concepts, let's now create a simple linear regression model. First, we have to import all the libraries and set a random seed, both for NumPy and TensorFlow (so that we'll all have the same results):

import tensorflow as tfimport numpy as npfrom datetime import datetimenp.random.seed(10)tf.set_random_seed(10)

Then, we can create a synthetic dataset consisting of 100 examples, as shown in the following screenshot:

Figure 2.4: Dataset used in the linear regression example

Because this is a linear regression example, y = W * X + b, where W and b are arbitrary values. In this example, we ...

Get Reinforcement Learning Algorithms 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.