summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2017-12-20 22:27:13 +0100
committerPatrick Simianer <p@simianer.de>2017-12-20 22:27:13 +0100
commit9ab3b807093e26c4ad1e3ad60e2431947e6f9ce0 (patch)
treed0e135e34adbf29f2dd2f4058127aa9e87dcd72d
parent32e8ad53760ad5743f39fd6a522ca7ba1e9516c3 (diff)
tensorflow
-rw-r--r--tensorflow/tf-cond.py9
1 files changed, 9 insertions, 0 deletions
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)