We proceed with the recipe as follows:
- To create the computational graph, we'll start by loading the following necessary libraries:
import matplotlib.pyplot as pltimport numpy as npimport tensorflow as tffrom sklearn import datasets
- Now we'll load the Iris data and store the length as the target value. Then we'll start a graph session with the following code:
iris = datasets.load_iris() x_vals = np.array([x[0:3] for x in iris.data]) y_vals = np.array([x[3] for x in iris.data]) sess = tf.Session()
- Since the dataset is smaller, we will want to set a seed to make the results reproducible, as follows:
seed = 2 tf.set_random_seed(seed) np.random.seed(seed)
- To prepare the data, we'll create a 80-20 train-test split and ...