O'Reilly logo

Deep Learning By Example by Ahmed Menshawy

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

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, ...

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