我試圖對(duì)簡(jiǎn)單的代碼執(zhí)行急切的執(zhí)行。我在 Jupyter Notebook 和 Spyder IDE 上都試過了。使用 Jupyter 我沒有問題,但是當(dāng)我在 Spyder 中執(zhí)行代碼時(shí),它返回一個(gè)錯(cuò)誤: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 tftf.enable_eager_execution ()import tensorflow.contrib.eager as tfedef square (x): return tf.multiply (x, x)grad = tfe.gradients_function (square)print (grad (3.))
必須僅在SPYDER IDE中的程序啟動(dòng)時(shí)調(diào)用tf.enable_eager_execution
桃花長(zhǎng)相依
2021-05-30 18:02:31