TensorFlow: “Cannot capture a stateful node by value” in tf.contrib.data API

梦想与她 提交于 2019-11-29 10:50:17

Unfortunately, tf.Variable is inherently stateful. However, this error only arises if you use Dataset.make_one_shot_iterator() to create the iterator.* To avoid the problem, you can instead use Dataset.make_initializable_iterator(), with the caveat that you must also run iterator.initializer on the returned iterator after running the initializer for the tf.Variable objects used in the input pipeline.


* The reason for this limitation is an implementation detail of Dataset.make_one_shot_iterator() and the work-in-progress TensorFlow function (Defun) support that it uses to encapsulate the dataset definition. Since using stateful resources like lookup tables and variables has been more popular than we initially imagined, we're looking into ways to relax this restriction.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!