问题
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