How to pass parmeters to functions inside tf.cond in Tensorflow?
<p>I have following simple placeholders:</p>

<pre><code>x = tf.placeholder(tf.float32, shape=[1])
y = tf.placeholder(tf.float32, shape=[1])
z = tf.placeholder(tf.float32, shape=[1])
</code></pre>

<p>There are two functions <code>fn1</code> and <code>fn2</code> defined as:</p>

<pre><code>def fn1(a, b): 
    return tf.mul(a, b)
def fn2(a, b): 
    return tf.add(a, b)
</code></pre>

<p>Now I want to calculate result based on pred condition:</p>

<pre><code>pred = tf.placeholder(tf.bool, shape=[1])
result = tf.cond(pred, fn1(x,y), fn2(y,z))
</code></pre>

<p>But it gives me an error saying <code>fn1 and fn2 must be callable</code>.</p>

<p>How can I write <code>fn1</code> and <code>fn2</code> so that they can receive parameters at runtime?
I want to call the following:</p>

<pre><code>sess.run(result, feed_dict={x:1,y:2,z:3,pred:True})
</code></pre>