Last active
January 13, 2017 07:08
-
-
Save jw0201/2d84f917729e85814fdfb0e1f3748f2f to your computer and use it in GitHub Desktop.
Revisions
-
jw0201 revised this gist
Jan 13, 2017 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -25,4 +25,7 @@ for step in xrange(2001): sess.run(train, feed_dict={X:x_data, Y:y_data}) if step % 20 == 0: print step, sess.run(cost, feed_dict={X:x_data, Y:y_data}), sess.run(W), sess.run(b) print sess.run(hypothesis, feed_dict={X:5}) print sess.run(hypothesis, feed_dict={X:2.5}) -
jw0201 created this gist
Jan 13, 2017 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ import tensorflow as tf x_data = [1., 2., 3.] y_data = [1., 2., 3.] X = tf.placeholder(tf.float32) Y = tf.placeholder(tf.float32) W = tf.Variable(tf.random_uniform([1], -1.0, 1.0)) b = tf.Variable(tf.random_uniform([1], -1.0, 1.0)) hypothesis = W * X + b cost = tf.reduce_mean(tf.square(hypothesis - Y)) a = tf.Variable(0.1) optimizer = tf.train.GradientDescentOptimizer(a) train = optimizer.minimize(cost) init = tf.initialize_all_variables() sess = tf.Session() sess.run(init) for step in xrange(2001): sess.run(train, feed_dict={X:x_data, Y:y_data}) if step % 20 == 0: print step, sess.run(cost, feed_dict={X:x_data, Y:y_data}), sess.run(W), sess.run(b)