提交 75ca4b54 authored 作者: Ian Goodfellow's avatar Ian Goodfellow

more compact error message

上级 a627b42f
...@@ -605,7 +605,6 @@ def get_scalar_constant_value(v): ...@@ -605,7 +605,6 @@ def get_scalar_constant_value(v):
if (leftmost_parent.owner and if (leftmost_parent.owner and
isinstance(leftmost_parent.owner.op, isinstance(leftmost_parent.owner.op,
theano.tensor.Shape)): theano.tensor.Shape)):
owner = v.owner
op = owner.op op = owner.op
idx_list = op.idx_list idx_list = op.idx_list
idx = idx_list[0] idx = idx_list[0]
...@@ -616,9 +615,16 @@ def get_scalar_constant_value(v): ...@@ -616,9 +615,16 @@ def get_scalar_constant_value(v):
assert ndim == len(gp_broadcastable) assert ndim == len(gp_broadcastable)
if not (idx < len(gp_broadcastable)): if not (idx < len(gp_broadcastable)):
raise ValueError("You are taking x.shape[i] on some tensor x, " msg = "get_scalar_constant_value detected " + \
"but x.ndim is %d and i is %d, so this is deterministically " "deterministic IndexError: x.shape[%d] " + \
"an index error." % (ndim, idx)) "when x.ndim=%d." % (ndim, idx)
if config.exception_verbosity == 'high':
msg += 'x=%s' % min_informative_str(x)
else:
msg += 'x=%s' % str(x)
raise ValueError(msg)
if gp_broadcastable[idx]: if gp_broadcastable[idx]:
return numpy.asarray(1) return numpy.asarray(1)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论