Linear regression with TensorFlow

For the first part, we will generate random data points and define a linear relation; we'll use TensorFlow to adjust and get the right parameters:

input_values = np.random.rand(100).astype(np.float32)

The equation for the model used in this example is:

Nothing special about this equation, it is just a model that we use to generate our data points. In fact, you can change the parameters to whatever you want, as you will do later. We add some Gaussian noise to the points to make it a bit more interesting:

output_values = input_values * 2 + 3output_values = np.vectorize(lambda y: y + np.random.normal(loc=0.0, ...

Get Deep Learning By Example 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.