提交 57a5f54c authored 作者: Frederic Bastien's avatar Frederic Bastien

Put all hints at the end of the error message.

this is more clear and allow to see all of them at once.
上级 9671ab34
...@@ -112,6 +112,7 @@ def raise_with_op(node, thunk=None, exc_info=None): ...@@ -112,6 +112,7 @@ def raise_with_op(node, thunk=None, exc_info=None):
if raise_with_op.print_thunk_trace: if raise_with_op.print_thunk_trace:
log_thunk_trace(exc_value) log_thunk_trace(exc_value)
hints = []
detailed_err_msg = "\nApply node that caused the error: " + str(node) detailed_err_msg = "\nApply node that caused the error: " + str(node)
types = [getattr(ipt, 'type', 'No type') for ipt in node.inputs] types = [getattr(ipt, 'type', 'No type') for ipt in node.inputs]
...@@ -138,8 +139,9 @@ def raise_with_op(node, thunk=None, exc_info=None): ...@@ -138,8 +139,9 @@ def raise_with_op(node, thunk=None, exc_info=None):
"\nInputs strides: %s" % strides + "\nInputs strides: %s" % strides +
"\nInputs scalar values: %s\n" % scalar_values) "\nInputs scalar values: %s\n" % scalar_values)
else: else:
detailed_err_msg += ("\nHINT: Use another linker then the c linker to" hints.append(
" have the inputs shapes and strides printed.") "HINT: Use another linker then the c linker to"
" have the inputs shapes and strides printed.")
# Print node backtrace # Print node backtrace
tr = getattr(node.tag, 'trace', None) tr = getattr(node.tag, 'trace', None)
...@@ -150,8 +152,11 @@ def raise_with_op(node, thunk=None, exc_info=None): ...@@ -150,8 +152,11 @@ def raise_with_op(node, thunk=None, exc_info=None):
detailed_err_msg += "\nBacktrace when the node is created:" detailed_err_msg += "\nBacktrace when the node is created:"
detailed_err_msg += str(tr) detailed_err_msg += str(tr)
else: else:
detailed_err_msg += ( hints.append(
"\nHINT: Re-running with most Theano optimization disabled could give you a back-traces when this node was created. This can be done with by setting the Theano flags optimizer=fast_compile\n") "HINT: Re-running with most Theano optimization disabled could"
" give you a back-traces when this node was created. This can"
" be done with by setting the Theano flags"
" optimizer=fast_compile")
if theano.config.exception_verbosity == 'high': if theano.config.exception_verbosity == 'high':
f = StringIO.StringIO() f = StringIO.StringIO()
...@@ -161,11 +166,12 @@ def raise_with_op(node, thunk=None, exc_info=None): ...@@ -161,11 +166,12 @@ def raise_with_op(node, thunk=None, exc_info=None):
detailed_err_msg += f.getvalue() detailed_err_msg += f.getvalue()
else: else:
detailed_err_msg += ("\nHINT: Use the Theano flag" hints.append(
" 'exception_verbosity=high'" "HINT: Use the Theano flag 'exception_verbosity=high'"
" for a debugprint of this apply node.") " for a debugprint of this apply node.")
exc_value = exc_type(str(exc_value) + detailed_err_msg) exc_value = exc_type(str(exc_value) + detailed_err_msg +
'\n' + '\n'.join(hints))
raise exc_type, exc_value, exc_trace raise exc_type, exc_value, exc_trace
raise_with_op.print_thunk_trace = False raise_with_op.print_thunk_trace = False
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论