必须仅在SPYDER IDE中的程序启动时调用tf.enable_eager_execution [英] tf.enable_eager_execution must be called at program startup ONLY in SPYDER IDE
本文介绍了必须仅在SPYDER IDE中的程序启动时调用tf.enable_eager_execution的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图对简单的代码执行急切的执行.
I have tried to perform an eager execution of a simple code.
我在Jupyter Notebook和Spyder IDE上都尝试过. 使用Jupyter,我没有问题,但是当我在Spyder中执行代码时,它将返回错误:
I've tried it on both Jupyter Notebook and Spyder IDE. With Jupyter I have no problem but when I execute the code in Spyder it returns an error:
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.))
推荐答案
键入Command + .
(在Mac上)或Ctrl + .
(在Windows上)以重新启动Spyder内核.
Type Command + .
(on Mac), or Ctrl + .
(on Windows) to restart your Spyder kernel.
这篇关于必须仅在SPYDER IDE中的程序启动时调用tf.enable_eager_execution的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文