首页 > 解决方案 > TensorFlow:NotFoundError:资源匿名迭代器错误

问题描述

我正在尝试复制在 https://www.tensorflow.org/beta/tutorials/text/time_series#multi-step_model上发布的在时间序列中使用 RNN 的示例

但是,我收到以下错误消息:

 NotFoundError: Resource AnonymousIterator/AnonymousIterator3/class 
 tensorflow::data::IteratorResource does not exist.
 [[{{node IteratorGetNext_3}}]]

当我尝试执行该行时:

for x, y in val_univariate.take(1):
print(simple_lstm_model.predict(x,steps=1).shape)

环境 :

Tenserflow : 2.0.0-beta1
Python : Python 3.6.7 Anaconda
OS : Windows 10 64-bit

有什么解决方案吗?

标签: pythontensorflowdeep-learninganacondarecurrent-neural-network

解决方案


来自TF 文档

它指出:

创建一个迭代器,用于枚举该数据集的元素。

返回的迭代器实现了 Python 迭代器协议,因此只能在急切模式下使用。

所以你需要tf.enable_eager_execution()在脚本的开头使用。


推荐阅读