<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Ch 03
Step1:  Define some constants used by the learning algorithm. There are called hyper-parameters.
Step2:  Set up fake data that we will use to to find a best fit line
Step3:  Plot the raw data
Step4:  Set up the input and output nodes as placeholders since the value will be injected by x_train and y_train.
Step5:  Define the model as y = w'*x
Step6:  Set up the weights variable
Step7:  Define the cost function as the mean squared error
Step8:  Define the operation that will be called on each iteration of the learning algorithm
Step9:  Initialize all variables
Step10:  Train on each (x, y) pair multiple times
Step11:  Fetch the value of the learned parameter
Step12:  Visualize the best fit curve
<ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
Explanation: Ch 03: Concept 01
Linear regression
Import TensorFlow for the learning algorithm. We'll need NumPy to set up the initial data. And we'll use matplotlib to visualize our data.
End of explanation
learning_rate = 0.01
training_epochs = 100
Explanation: Define some constants used by the learning algorithm. There are called hyper-parameters.
End of explanation
x_train = np.linspace(-1, 1, 101)
y_train = 2 * x_train + np.random.randn(*x_train.shape) * 0.33
Explanation: Set up fake data that we will use to to find a best fit line
End of explanation
plt.scatter(x_train, y_train)
Explanation: Plot the raw data
End of explanation
X = tf.placeholder("float")
Y = tf.placeholder("float")
Explanation: Set up the input and output nodes as placeholders since the value will be injected by x_train and y_train.
End of explanation
def model(X, w):
    return tf.multiply(X, w)
Explanation: Define the model as y = w'*x
End of explanation
w = tf.Variable(0.0, name="weights")
Explanation: Set up the weights variable
End of explanation
y_model = model(X, w)
cost = tf.reduce_mean(tf.square(Y-y_model))
Explanation: Define the cost function as the mean squared error
End of explanation
train_op = tf.train.GradientDescentOptimizer(learning_rate).minimize(cost)
Explanation: Define the operation that will be called on each iteration of the learning algorithm
End of explanation
sess = tf.Session()
init = tf.global_variables_initializer()
sess.run(init)
Explanation: Initialize all variables
End of explanation
for epoch in range(training_epochs):
    for (x, y) in zip(x_train, y_train):
        sess.run(train_op, feed_dict={X: x, Y: y})
Explanation: Train on each (x, y) pair multiple times
End of explanation
w_val = sess.run(w)
sess.close()
Explanation: Fetch the value of the learned parameter
End of explanation
plt.scatter(x_train, y_train)
y_learned = x_train*w_val
plt.plot(x_train, y_learned, 'r')
plt.show()
Explanation: Visualize the best fit curve
End of explanation
<END_TASK>