小编Jos*_*Ong的帖子

错误:TensorFlow:tf.enable_eager_execution 必须在程序启动时调用

我正在尝试修改来自github 的代码:

我收到此错误:

tf.enable_eager_execution must be called at program startup.
Run Code Online (Sandbox Code Playgroud)

我认为它来自这些代码行:

from __future__ import print_function
import make_dataset

import tensorflow as tf
import tensorflow.contrib.eager as tfe
tf.enable_eager_execution()
Run Code Online (Sandbox Code Playgroud)

另外,我认为我需要急切执行的原因是因为在我的 with tf.session 块中:

使用 tf.Session() 作为 sess:

# Run the initializer
sess.run(iterator.initializer)

for step in range(1, num_steps+1):
    batch_x, batch_y = myDataset.batch(4)#line where error occurs
    # Run optimization op (backprop)
    sess.run(train_op, feed_dict={X: batch_x, Y: batch_y})
Run Code Online (Sandbox Code Playgroud)

我收到错误:

RuntimeError: dataset.__iter__() is only supported when eager execution is enabled

因此,决定更改迭代器或启用急切执行的指导将非常有用。

非常感谢,乔希

python tensorflow tensorflow2.0

5
推荐指数
2
解决办法
1万
查看次数

标签 统计

python ×1

tensorflow ×1

tensorflow2.0 ×1