Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tf.enable_eager_execution must be called at program startup ONLY in SPYDER IDE

I have tried to perform an eager execution of a simple code.

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.

and the code is as follows:

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.))
like image 617
Blunt Avatar asked Jan 27 '23 13:01

Blunt


1 Answers

Type Command + . (on Mac), or Ctrl + . (on Windows) to restart your Spyder kernel.

like image 95
Ekaba Bisong Avatar answered Jan 31 '23 18:01

Ekaba Bisong