tf.cond
import tensorflow as tf
x = tf.constant(12)
y = tf.constant(5)
def f1(): return tf.multiply(x, 17)
def f2(): return tf.add(y, 23)
r = tf.cond(tf.less(x, y), f1, f2)print(r.numpy())
如果 x<y,就執行函數 f1 , 否則 就執行 f2
28總結
- 上一篇: tf.clip_by_value
- 下一篇: python 程序开机自启动,亲测可用