How to do it...

We proceed with the recipe as follows:

  1. We will set up the system in exactly the same way as the previous recipe. We will import libraries, initialize the graph, and create the data. Then, we will obtain our A matrix and b matrix in the say way we did previously:
import matplotlib.pyplot as plt import numpy as np import tensorflow as tf from tensorflow.python.framework import ops ops.reset_default_graph() sess = tf.Session() x_vals = np.linspace(0, 10, 100) y_vals = x_vals + np.random.normal(0, 1, 100) x_vals_column = np.transpose(np.matrix(x_vals)) ones_column = np.transpose(np.matrix(np.repeat(1, 100))) A = np.column_stack((x_vals_column, ones_column)) b = np.transpose(np.matrix(y_vals)) A_tensor = tf.constant(A) b_tensor ...

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.