tf.cond和tf.case
来源:互联网 发布:c语言编Newton 编辑:程序博客网 时间:2024/05/22 00:18
tensorflow的逻辑控制
关于tf.case理解的不是很好:
https://stackoverflow.com/questions/41910073/tensorflow-tf-case-f-default-should-do-nothing
待明确后再补充
关于tf.cond,这里给出几个示例,对我来说,例子就是快速明白用法的途径
import tensorflow as tfa=tf.constant(2)b=tf.constant(3)x=tf.constant(4)y=tf.constant(5)z = tf.multiply(a, b)result = tf.cond(x > y, lambda: tf.add(x, z), lambda: tf.square(y))with tf.Session() as session: print(result.eval())
运行的结果是25
根据第7行代码,如果x>y为true,就执行tf.add(x, z), 否则就执行tf.square(y)
示例二:
运行的结果是:2
如果注释第8行,取消注释第9行,此时运行的结果是1
阅读全文
0 0
- tf.cond和tf.case
- tf.where 和 tf.cond对比
- tf.cond()的用法
- tf.cond 与 tf.control_dependencies 的控制问题
- TF
- tf
- 理解TF和TF-IDF
- tf.get_variable 和tf.variable_scope
- tf.sign和tf.reduce_sum
- tf.sign和tf.reduce_sum
- tf.arg_max和tf.argmax
- tf.get_variable 和tf.variable_scope
- tf.get_variable 和tf.variable_scope
- tf 深入Time和TF
- tf.gather和tf.slice
- tf.control_dependencies()和tf.identity()
- tf.stack和tf.unstack
- tf.add_to_collection,tf.get_collection和tf.add_n的用法
- 情绪体验和压力调节
- spice-client源码解析之application.cpp
- 两个数的交换,代码简单,不必观看
- HQL语句的用法
- 动态规划DP学习及应用
- tf.cond和tf.case
- 不为情怀,忠于技术!
- hdu Number Sequence
- 需求测试注意事项有哪些
- redis集群
- CentOS 6.9 环境配置
- spingboot入门步骤
- ||homework||用Python统计excel文件中特征值的个数
- Spark2启动报错