TensorFlow

Table of Contents

Overview

Reference

placeholder

x = tf.placeholder(tf.float32, shape=(1024, 1024))
y = tf.matmul(x, x)

with tf.Session() as sess:
  print(sess.run(y))  # ERROR: will fail because x was not fed.

  rand_array = np.random.rand(1024, 1024)
  print(sess.run(y, feed_dict={x: rand_array}))  # Will succeed.

getvariable

def foo():
  with tf.variable_scope("foo", reuse=tf.AUTO_REUSE):
    v = tf.get_variable("v", [1])
  return v

v1 = foo()  # Creates v.
v2 = foo()  # Gets the same, existing v.
assert v1 == v2

train.AdamOptimizer

train_op = tf.train.AdamOptimizer(learning_rate=kjjkk1e-4).minimize(cross_entropy)

xavierinitializer

tf.get_variable("W", [3, 3, 3, 8], initializer=tf.contrib.layers.xavier_initializer())

sess.run

_, c = sess.run([optimizer cost], feed_dict={X: minibatch_X, Y: minibatch_Y})

cast

tf.cast(loss, tf.float32)

Terminology

Topics

How-to

Links