提交 6187e961 authored 作者: Iban Harlouchet's avatar Iban Harlouchet

Added __props__ and removed __eq__, __hash__ to extra_ops.py

上级 2207c24f
...@@ -12,16 +12,11 @@ tensor = basic ...@@ -12,16 +12,11 @@ tensor = basic
class CumsumOp(theano.Op): class CumsumOp(theano.Op):
# See function cumsum for docstring # See function cumsum for docstring
__props__=("axis")
def __init__(self, axis=None): def __init__(self, axis=None):
self.axis = axis self.axis = axis
def __eq__(self, other):
return (type(self) == type(other) and
self.axis == other.axis)
def __hash__(self):
return hash(type(self)) ^ hash(self.axis)
def make_node(self, x): def make_node(self, x):
x = basic.as_tensor_variable(x) x = basic.as_tensor_variable(x)
out_type = x.type() out_type = x.type()
...@@ -134,16 +129,11 @@ def cumsum(x, axis=None): ...@@ -134,16 +129,11 @@ def cumsum(x, axis=None):
class CumprodOp(theano.Op): class CumprodOp(theano.Op):
# See function cumprod for docstring # See function cumprod for docstring
__props__=("axis")
def __init__(self, axis=None): def __init__(self, axis=None):
self.axis = axis self.axis = axis
def __eq__(self, other):
return (type(self) == type(other) and
self.axis == other.axis)
def __hash__(self):
return hash(type(self)) ^ hash(self.axis)
def make_node(self, x): def make_node(self, x):
x = basic.as_tensor_variable(x) x = basic.as_tensor_variable(x)
out_type = x.type() out_type = x.type()
...@@ -258,6 +248,8 @@ def cumprod(x, axis=None): ...@@ -258,6 +248,8 @@ def cumprod(x, axis=None):
class DiffOp(theano.Op): class DiffOp(theano.Op):
# See function diff for docstring # See function diff for docstring
__props__=("n", "axis")
def __init__(self, n=1, axis=-1): def __init__(self, n=1, axis=-1):
self.n = n self.n = n
self.axis = axis self.axis = axis
...@@ -266,14 +258,6 @@ class DiffOp(theano.Op): ...@@ -266,14 +258,6 @@ class DiffOp(theano.Op):
if n == 0: if n == 0:
self.view_map = {0: [0]} self.view_map = {0: [0]}
def __eq__(self, other):
return (type(self) == type(other) and
self.n == other.n and
self.axis == other.axis)
def __hash__(self):
return hash(type(self)) ^ hash(self.n) ^ hash(self.axis)
def make_node(self, x): def make_node(self, x):
x = basic.as_tensor_variable(x) x = basic.as_tensor_variable(x)
return theano.Apply(self, [x], [x.type()]) return theano.Apply(self, [x], [x.type()])
...@@ -339,6 +323,7 @@ class BinCountOp(theano.Op): ...@@ -339,6 +323,7 @@ class BinCountOp(theano.Op):
compatible_type = ('int8', 'int16', 'int32', 'int64', compatible_type = ('int8', 'int16', 'int32', 'int64',
'uint8', 'uint16', 'uint32', 'uint64') 'uint8', 'uint16', 'uint32', 'uint64')
"""Tuple of all compatible dtype for the parameter of this op.""" """Tuple of all compatible dtype for the parameter of this op."""
__props__=("minlength")
def __init__(self, minlength=None): def __init__(self, minlength=None):
self.minlength = minlength self.minlength = minlength
...@@ -349,13 +334,6 @@ class BinCountOp(theano.Op): ...@@ -349,13 +334,6 @@ class BinCountOp(theano.Op):
"BinCountOp with minlength attribute" "BinCountOp with minlength attribute"
" requires NumPy 1.6 or higher.") " requires NumPy 1.6 or higher.")
def __eq__(self, other):
return (type(self) == type(other) and
self.minlength == other.minlength)
def __hash__(self):
return hash(type(self)) ^ hash(self.minlength)
def make_node(self, x, weights): def make_node(self, x, weights):
warnings.warn(( warnings.warn((
"Tile op is deprecated, use tile function instead."), "Tile op is deprecated, use tile function instead."),
...@@ -533,17 +511,11 @@ def compress(condition, x, axis=None): ...@@ -533,17 +511,11 @@ def compress(condition, x, axis=None):
class RepeatOp(theano.Op): class RepeatOp(theano.Op):
# See the repeat function for docstring # See the repeat function for docstring
__props__=("axis")
def __init__(self, axis=None): def __init__(self, axis=None):
self.axis = axis self.axis = axis
def __eq__(self, other):
return (type(self) == type(other) and
self.axis == other.axis)
def __hash__(self):
return hash(type(self)) ^ hash(self.axis)
def make_node(self, x, repeats): def make_node(self, x, repeats):
x = basic.as_tensor_variable(x) x = basic.as_tensor_variable(x)
repeats = basic.as_tensor_variable(repeats) repeats = basic.as_tensor_variable(repeats)
...@@ -712,12 +684,8 @@ def repeat(x, repeats, axis=None): ...@@ -712,12 +684,8 @@ def repeat(x, repeats, axis=None):
class Bartlett(gof.Op): class Bartlett(gof.Op):
# See function bartlett for docstring # See function bartlett for docstring
def __eq__(self, other): __props__=()
return type(self) == type(other)
def __hash__(self):
return hash(type(self))
def __str__(self): def __str__(self):
return self.__class__.__name__ return self.__class__.__name__
...@@ -774,11 +742,7 @@ def bartlett(M): ...@@ -774,11 +742,7 @@ def bartlett(M):
class FillDiagonal(gof.Op): class FillDiagonal(gof.Op):
# See function fill_diagonal for docstring # See function fill_diagonal for docstring
def __eq__(self, other): __props__=()
return type(self) == type(other)
def __hash__(self):
return hash(type(self))
def __str__(self): def __str__(self):
return self.__class__.__name__ return self.__class__.__name__
...@@ -862,11 +826,7 @@ def fill_diagonal(a, val): ...@@ -862,11 +826,7 @@ def fill_diagonal(a, val):
class FillDiagonalOffset(gof.Op): class FillDiagonalOffset(gof.Op):
# See function fill_diagonal_offset for docstring # See function fill_diagonal_offset for docstring
def __eq__(self, other): __props__=()
return type(self) == type(other)
def __hash__(self):
return hash(type(self))
def __str__(self): def __str__(self):
return self.__class__.__name__ return self.__class__.__name__
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论