Skip to content

Instantly share code, notes, and snippets.

@Oktai15
Last active April 30, 2018 10:19
Show Gist options
  • Save Oktai15/c2369a1603ea4ed376c9a7defaea836f to your computer and use it in GitHub Desktop.
Save Oktai15/c2369a1603ea4ed376c9a7defaea836f to your computer and use it in GitHub Desktop.
TensorFlow: simple example conditional
# update for https://gist.github.com/Oktai15/4b6617b916c0fa4feecab35be09c1bd6
a = tf.constant(10)
data = tf.placeholder(tf.float32, shape=(data_size, input_size))
h1_w1 = tf.placeholder(tf.float32, shape=(input_size, hidden1_output))
h2_w1 = tf.placeholder(tf.float32, shape=(input_size, hidden1_output))
def first(): return tf.matmul(data, h1_w1)
def second(): return tf.matmul(data, h2_w1)
hidden1_out = tf.cond(tf.greater(a, 0), first, second)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment