提交 04416cc5 authored 作者: James Bergstra's avatar James Bergstra

fix that made a really weird integer-array filtering error go away

上级 e852bb47
......@@ -130,6 +130,12 @@ class BadDestroyMap(DebugModeError):
print >> sio, " changed input type:", self.node.inputs[self.idx].type
print >> sio, " repr (old val):", repr(self.old_val)
print >> sio, " repr (new val):", repr(self.new_val)
print >> sio, " value dtype (new <space> old):", self.new_val.dtype, self.old_val.dtype
print >> sio, " value shape (new <space> old):", self.new_val.shape, self.old_val.shape
print >> sio, " value min (new <space> old):", self.new_val.min(), self.old_val.min()
print >> sio, " value max (new <space> old):", self.new_val.max(), self.old_val.max()
print >> sio, " value min (new-old):", (self.new_val-self.old_val).min()
print >> sio, " value max (new-old):", (self.new_val-self.old_val).max()
print >> sio, ""
print >> sio, " Hint: this can also be caused by a deficient values_eq_approx() or __eq__() implementation that compares node input values"
return sio.getvalue()
......
......@@ -250,11 +250,16 @@ class TensorType(Type):
if type(a) is numpy.ndarray and type(b) is numpy.ndarray:
if a.shape != b.shape:
return False
if a.shape == ():
ones = numpy.ones(2)
return numpy.allclose(ones * a, ones*b)
if a.dtype != b.dtype:
return False
if 'int' in str(a.dtype):
return numpy.all(a==b)
else:
return numpy.allclose(a,b)
if a.shape == (): #for comparing scalars, use broadcasting.
ones = numpy.ones(2)
return numpy.allclose(ones * a, ones*b)
else:
return numpy.allclose(a,b)
return False
def __hash__(self):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论