提交 63fb1356 authored 作者: James Bergstra's avatar James Bergstra

Adjusted hash, eq, and str of Reshape to use type(self) and self.__class__

instead of 'Reshape' directly. This is friendlier to subclasses.
上级 bef27274
......@@ -2254,10 +2254,12 @@ class Reshape(Op):
def __eq__(self, other):
# .name does not participate because it doesn't affect computations
return (type(other) is Reshape) and (other.ndim == self.ndim)
return (type(other) is type(self)) and (other.ndim == self.ndim)
def __hash__(self):
# .name does not participate because it doesn't affect computations
return hash(Reshape) ^ hash(self.ndim)
return hash(type(other)) ^ hash(self.ndim)
def __str__(self):
return '%s{%s}' %(self.__class__.__name__, self.ndim)
def make_node(self, x, shp):
x = as_tensor_variable(x)
shp = as_tensor_variable(shp)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论