Basics of Graphs / Flow Control

Intermediate values are not stored unless you query them in the same session run. You can do so, for example, with

sess.run([z, x, y])

I don’t think you need the tf.control_dependencies. The following works:

z = Poisson(tf.ones(1))
zp = 1.0 * z
comparison = tf.equal(zp, tf.zeros(1))
def if_false():
  y = Gamma(concentration=tf.ones(1), rate=zp)
  return y
def if_true():
  x = Normal(loc=zp, scale=0.005 * tf.ones(1))
  return x
new_rv = tf.where(comparison, if_true, if_false)

See previous answer for tensors you have access to. For values inside the body of a function, things are a bit more difficult. You’d have to get them to be outputted to a tensor in some way.