Last active
May 23, 2017 19:34
-
-
Save AbhinavMadahar/96c7c4c8fb60607390fa0990b48242bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
weights = tf.Variable([1., 2., 3.],tf.float32) | |
biases = tf.Variable([4., 5., 6.], tf.float32) | |
x = tf.placeholder(tf.float32) | |
sess = tf.Session() | |
linear_model = weights * x + biases | |
sess.run(tf.global_variables_initializer()) | |
y = tf.placeholder(tf.float32) | |
squared_deltas = tf.square(linear_model - y) | |
loss = tf.reduce_sum(squared_deltas) | |
optimizer = tf.train.GradientDescentOptimizer(0.01) | |
train = optimizer.minimize(loss) | |
print(sess.run([loss, weights, biases], {x:[1,2,3], y:[0,-1,-2]})) | |
for i in range(1000): | |
sess.run(train, {x:[1,2,3], y:[0,-1,-2]}) | |
print(sess.run([loss, weights, biases], {x:[1,2,3], y:[0,-1,-2]})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment