提交 178d49ba authored 作者: Frederic's avatar Frederic

Better error message.

上级 29e7c420
...@@ -4,8 +4,10 @@ fg.py: fg stands for FunctionGraph ...@@ -4,8 +4,10 @@ fg.py: fg stands for FunctionGraph
Contains the FunctionGraph class and exception Contains the FunctionGraph class and exception
types that it can raise types that it can raise
""" """
import StringIO
import sys import sys
import time import time
import traceback
import theano import theano
from theano.gof import graph from theano.gof import graph
...@@ -328,18 +330,29 @@ class FunctionGraph(utils.object2): ...@@ -328,18 +330,29 @@ class FunctionGraph(utils.object2):
#if there is no path then r isn't really a graph input so we shouldn't be running error #if there is no path then r isn't really a graph input so we shouldn't be running error
#handler code in the first place #handler code in the first place
assert path is not None assert path is not None
tr = getattr(r.tag, 'trace', None)
raise MissingInputError(( detailed_err_msg = ""
if tr:
sio = StringIO.StringIO()
traceback.print_list(tr, sio)
tr = sio.getvalue()
detailed_err_msg += "\nBacktrace when the variable is created:\n"
detailed_err_msg += str(tr)
raise MissingInputError(
'A variable that is an input to the graph was ' 'A variable that is an input to the graph was '
'neither provided as an input to the function ' 'neither provided as an input to the function '
'nor given a value. A chain of variables ' 'nor given a value. A chain of variables '
'leading from this input to an output is %s. ' 'leading from this input to an output is %s. '
'This chain may not be unique' % str(path))) 'This chain may not be unique' % str(path) +
detailed_err_msg)
#Standard error message #Standard error message
raise MissingInputError(( raise MissingInputError((
"An input of the graph, used to compute %s, " "An input of the graph, used to compute %s, "
"was not provided and not given a value" "was not provided and not given a value."
"Use the Theano flag exception_verbosity='high',"
"for more information on this error."
% str(node)), % str(node)),
r) r)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论