我试着对一个简单的代码执行一个急切的执行。
我在Jupyter笔记本和Spyder IDE上都试过。 对于Jupyter,我没有问题,但是当我在Spyder中执行代码时,它会返回一个错误:
File "C:\...\lib\site-packages\tensorflow\python\framework\ops.py", line 5496, in enable_eager_execution "tf.enable_eager_execution must be called at program startup.")
ValueError: tf.enable_eager_execution must be called at program startup.
代码如下:
import tensorflow as tf
tf.enable_eager_execution ()
import tensorflow.contrib.eager as tfe
def square (x):
return tf.multiply (x, x)
grad = tfe.gradients_function (square)
print (grad (3.))
目前没有回答
相关问题 更多 >
编程相关推荐