提交 9b5901c2 authored 作者: Frederic Bastien's avatar Frederic Bastien

make CAReduce raise the same error type as numpy when the axis is wrong and make…

make CAReduce raise the same error type as numpy when the axis is wrong and make it check negative axis.
上级 1d5c85cf
...@@ -882,8 +882,8 @@ class CAReduce(Op): ...@@ -882,8 +882,8 @@ class CAReduce(Op):
def make_node(self, input): def make_node(self, input):
if self.axis is not None: if self.axis is not None:
for axis in self.axis: for axis in self.axis:
if axis >= input.type.ndim: if axis >= input.type.ndim or (axis<0 and abs(axis)>input.type.ndim):
raise TypeError('Not enough dimensions on %s to reduce on axis %s' % (input, axis)) raise ValueError('Not enough dimensions on %s to reduce on axis %s' % (input, axis))
input = as_tensor_variable(input) input = as_tensor_variable(input)
axis = self.axis axis = self.axis
if axis is None: if axis is None:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论