Tensorflow 1.X basics
Tensorflow 1.X basics
Here are the basics steps necessary to write TensorFlow code.
Note that this is for TensorFlow 1.X
Define constants
a = tf.constant(5.0)
Define variables
x = tf.Variable(init_value)
Define placeholders
p = tf.placeholder(tf.float32)
Define operations
c = x * x
Define way to measure loss
loss=tf.reduce_mean(tf.square(output - y))
Define optimizer
optimizer = tf.train.AdamOptimizer(learning_rate)
Apply optimizer to loss function
train = optimizer.minimize(loss)
init variables
init = tf.globalvariablesinitializer()
Run everything in a session
with tf.Session() as sess:
sess.run(init)
for epoch in range(epoch_count):
sess.run(train, feed_dict={<feedDictHere})