tensorflowUsing if condition inside the TensorFlow graph with tf.cond


Parameters

ParameterDetails
preda TensorFlow tensor of type bool
fn1a callable function, with no argument
fn2a callable function, with no argument
name(optional) name for the operation

Remarks

  • pred cannot be just True or False, it needs to be a Tensor
  • The function fn1 and fn2 should return the same number of outputs, with the same types.