提交 e32c6ff0 authored 作者: David Warde-Farley's avatar David Warde-Farley

Merge branch 'tensor_mean_ndarray_crash'

...@@ -2624,7 +2624,7 @@ def mean(input, axis = None, op = False): ...@@ -2624,7 +2624,7 @@ def mean(input, axis = None, op = False):
axis = [axis] axis = [axis]
for i in axis: for i in axis:
s = s / shp[i] s = s / shp[i]
if input.dtype.startswith('float'): if str(input.dtype).startswith('float'):
assert input.dtype == s.dtype assert input.dtype == s.dtype
return s return s
......
...@@ -1021,6 +1021,8 @@ class CAReduce(Op): ...@@ -1021,6 +1021,8 @@ class CAReduce(Op):
return input_dtype return input_dtype
def make_node(self, input): def make_node(self, input):
input = as_tensor_variable(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 or (axis<0 and abs(axis)>input.type.ndim): if axis >= input.type.ndim or (axis<0 and abs(axis)>input.type.ndim):
......
...@@ -2918,6 +2918,14 @@ class T_divimpl(unittest.TestCase): ...@@ -2918,6 +2918,14 @@ class T_divimpl(unittest.TestCase):
assert numpy.allclose(function([i, ii, d, f, c], true_div(ii,i))(5, 3, 7.0, 11.0, numpy.complex(5,3)), assert numpy.allclose(function([i, ii, d, f, c], true_div(ii,i))(5, 3, 7.0, 11.0, numpy.complex(5,3)),
(3./5.)) (3./5.))
class T_mean(unittest.TestCase):
def test_regression_mean_of_ndarray_failure(self):
try:
T.mean(numpy.zeros(1))
except AttributeError:
self.fail()
# class T_abs(unittest.TestCase): # class T_abs(unittest.TestCase):
# def test_impl(self): # def test_impl(self):
# t = as_tensor_variable(1.0) # t = as_tensor_variable(1.0)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论