1. 使用tf.cond/tf.case:
报错:
TypeError: true_fn must be callable.
解决:
tf.cond(a < b, f1, f2) -> tf.cond(a < b, lambda : f1, lambda: f2)
本文针对 TensorFlow 中 tf.cond 函数的使用进行了详细说明,并解决了在使用过程中出现的 TypeError 报错问题,即 true_fn must be callable 的错误。通过具体的示例对比了错误用法与正确用法之间的区别。
1. 使用tf.cond/tf.case:
报错:
TypeError: true_fn must be callable.
解决:
tf.cond(a < b, f1, f2) -> tf.cond(a < b, lambda : f1, lambda: f2)

被折叠的 条评论
为什么被折叠?