In [1]:
import tensorflow as tf


/home/seung/kerasTF_python3/lib/python3.5/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters

In [5]:
x = tf.placeholder(dtype=tf.float32)
y = tf.placeholder(dtype=tf.float32)

In [6]:
result = tf.cond(x < y, lambda: tf.add(x, y), lambda: tf.square(y))

In [7]:
sess= tf.InteractiveSession()

cond returns tensors returned by the call to either true_fn or false_fn


In [11]:
r1 = sess.run(result, feed_dict={x: 1.0, y: 2.0})
print(r1)


3.0

In [12]:
r1 = sess.run(result, feed_dict={x: 3.0, y: 2.0})
print(r1)


4.0