How to do it...

First, we will show how to evaluate the simple regression model that simply fits a constant multiplication to the target, which is 10, as follows:

  1. First, we start by loading the libraries and creating the graph, data, variables, and placeholders. There is an additional part to this section that is very important. After we create the data, we will split the data into training and test datasets randomly. This is important because we will always test our models to see whether they are predicting well or not. Evaluating the model both on the training data and test data also lets us see whether the model is overfitting or not:
import matplotlib.pyplot as plt import numpy as np import tensorflow as tf sess = tf.Session() x_vals ...

Get TensorFlow Machine Learning Cookbook - Second Edition 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.