Skip to content
Advertisement

Tensorflow: tf.cond, how to return multi dim tensors instead of simple values?

When I run my code:

JavaScript

I get:

run(bool_tensor) : [False True False]

ValueError: Shape must be rank 0 but is rank 1 for ‘cond/Switch’ (op: ‘Switch’) with input shapes: [3], [3].

But I want the second print to show a Tensor that evaluates to: [-999 999 -999]

I have looked into other posts but could find a solution.

Thank you

p.s: I use Tensorflow 1

Advertisement

Answer

Try using tf.where:

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement