tensorflow2_tutorials_chinese icon indicating copy to clipboard operation
tensorflow2_tutorials_chinese copied to clipboard

为什么我的tensorflow2.0不支持python的if 还有while 这些语句,即使我加了@tf.function

Open yuanzhoulvpi2017 opened this issue 5 years ago • 4 comments

yuanzhoulvpi2017 avatar May 06 '19 16:05 yuanzhoulvpi2017

image 你那边说的不支持是什么意思,功能无效吗?发一下具体代码。 我这边可以正常运行

czy36mengfei avatar May 07 '19 06:05 czy36mengfei

image 出现这个结果, TypeError: Using a tf.Tensor as a Python bool is not allowed. Use if t is not None: instead of if t: to test if a tensor is defined, and use TensorFlow ops such as tf.cond to execute subgraphs conditioned on the value of a tensor. 我这个是2.0哇,不知道为什么,

yuanzhoulvpi2017 avatar May 09 '19 03:05 yuanzhoulvpi2017

可能命令行单条输入,它不能事先构造好图直接执行了。喜欢交互式输入欢迎使用jupyter-notebook,你会喜欢上它的

czy36mengfei avatar May 10 '19 16:05 czy36mengfei

原来是这个原因,我回去用jupyter-notebook试一试,不能在命令行使用,算不算bug?

yuanzhoulvpi2017 avatar May 11 '19 01:05 yuanzhoulvpi2017