提交 04b052e4 authored 作者: nouiz's avatar nouiz

Merge pull request #327 from goodfeli/b

added verbose exception for elemwise perform
......@@ -995,7 +995,7 @@ def min_informative_str(obj, indent_level=0,
indent = ' ' * indent_level
if obj in _prev_obs:
if id(obj) in _prev_obs:
tag = _prev_obs[obj]
return indent + '<' + tag + '>'
......@@ -1005,7 +1005,7 @@ def min_informative_str(obj, indent_level=0,
cur_tag = _tag_generator.get_tag()
_prev_obs[obj] = cur_tag
_prev_obs[id(obj)] = cur_tag
if hasattr(obj, '__array__'):
name = '<ndarray>'
......
......@@ -8,8 +8,10 @@ from theano import gof
from theano.gof import Apply, Op
from theano import scalar
from theano.scalar import Scalar
from theano.printing import pprint
from theano.printing import min_informative_str, pprint
from theano.gof.python25 import all, any
config = theano.config
# tensor depends on elemwise to provide definitions for several ops
......@@ -685,8 +687,15 @@ class Elemwise(Op):
msg2 += [str(d)]
msg.append('(%s)' % ", ".join(msg2))
raise ValueError('Dimension mismatch; shapes are %s' %
', '.join(msg))
base_exc_str = 'Dimension mismatch; shapes are %s' % (', '.join(msg))
if config.exception_verbosity == 'high':
msg_chunks = [ base_exc_str ]
for i, ipt in enumerate(node.inputs):
msg_chunks.append('input %d: %s' % (i, min_informative_str(ipt)))
raise ValueError('\n'.join(msg_chunks))
else:
raise ValueError(base_exc_str)
#', '.join('(%s)' % ', '.join(msg)))
#backport
#raise ValueError('Dimension mismatch; shapes are %s' %
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论