Trying to run the following basic example to run a conditional calculation I got the following error message:
'x' was passed float incompatible with expected float_ref
what is a tensorflow float_ref and how does the code have to be modified?
import tensorflow as tf
from tensorflow.python.ops.control_flow_ops import cond
a = tf.Variable(tf.constant(0.),name="a")
b = tf.Variable(tf.constant(0.),name="b")
x = tf.Variable(tf.constant(0.),name="x")
def add():
x.assign( a + b)
return x
def last():
return x
calculate= cond(x==0.,add,last)
with tf.Session() as s:
val = s.run([calculate], {a: 1., b: 2., x: 0.})
print(val) # 3
val=s.run([calculate],{a:4.,b:5.,x:val})
print(val) # 3