Skip to content

Instantly share code, notes, and snippets.

@BinRoot
Created June 19, 2017 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BinRoot/6c0b681e7a0c16a50368c723e89df50f to your computer and use it in GitHub Desktop.
Save BinRoot/6c0b681e7a0c16a50368c723e89df50f to your computer and use it in GitHub Desktop.
import tensorflow as tf
x = tf.Variable(2, name='x', dtype=tf.float32)
log_x = tf.log(x)
y = tf.square(log_x) + 1
optimizer = tf.train.GradientDescentOptimizer(0.5)
train = optimizer.minimize(y)
init = tf.global_variables_initializer()
with tf.Session() as sess:
sess.run(init)
for step in range(10):
x_val, y_val = sess.run([x, y])
print('x: {}, y: {}'.format(x_val, y_val))
sess.run(train)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment