From 9ab3b807093e26c4ad1e3ad60e2431947e6f9ce0 Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Wed, 20 Dec 2017 22:27:13 +0100 Subject: tensorflow --- tensorflow/tf-cond.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 tensorflow/tf-cond.py (limited to 'tensorflow') diff --git a/tensorflow/tf-cond.py b/tensorflow/tf-cond.py new file mode 100644 index 0000000..13c1bc3 --- /dev/null +++ b/tensorflow/tf-cond.py @@ -0,0 +1,9 @@ +import tensorflow as tf + +sess = tf.Session() +x = tf.constant(0) +a = sess.run( + [tf.cond(tf.equal(tf.count_nonzero(x), 0), lambda: tf.constant(True, name="b"), lambda: tf.constant(False,name="a"))] +) + +print(a) -- cgit v1.2.3