Here is how the regression example works:
- We start by loading the numpy and tensorflow numerical Python packages:
import numpy as np import tensorflow as tf
- Now, we start a graph session:
sess = tf.Session()
- Next, we create the data, placeholders, and the A variable:
x_vals = np.random.normal(1, 0.1, 100) y_vals = np.repeat(10., 100) x_data = tf.placeholder(shape=[1], dtype=tf.float32) y_target = tf.placeholder(shape=[1], dtype=tf.float32) A = tf.Variable(tf.random_normal(shape=[1]))
- We add the multiplication operation to our graph:
my_output = tf.mul(x_data, A)
- Next, we add our L2 Loss function between the multiplication output and the target data:
loss = tf.square(my_output - y_target)
- Now, we have to declare ...