dynamically catch exceptions in TensorFlow as part of the graph execution

烈酒焚心 提交于 2021-01-27 12:12:08

问题


E.g. the QueueBase.dequeue function can raise an OutOfRangeError exception which I will receive in Python from the Session.run call. Is there any way I can catch the exception inside the graph, similar as tf.cond? E.g. something like:

result = tf.on_exception(queue.dequeue(), lambda: 42)

Maybe also the first argument would need to be a lambda such that it can properly set the context. To make this work, like in tf.cond, the result from both arguments would need to be of the same type.


回答1:


No. As far as I know, there is no way to handle exceptions in graph, exception handling is done in python. Besides, queue runners run in threads separate from main graph execution anyway.



来源:https://stackoverflow.com/questions/44137542/dynamically-catch-exceptions-in-tensorflow-as-part-of-the-graph-execution

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