提交 c5e8a93c authored 作者: Frédéric Bastien's avatar Frédéric Bastien

Merge pull request #3181 from harlouci/props_sandbox

Props sandbox
...@@ -11,6 +11,9 @@ from theano.gof import Op, Apply, generic ...@@ -11,6 +11,9 @@ from theano.gof import Op, Apply, generic
class GradTodo(Op): class GradTodo(Op):
__props__ = ()
def make_node(self, x): def make_node(self, x):
return Apply(self, [x], [x.type()]) return Apply(self, [x], [x.type()])
...@@ -40,22 +43,12 @@ class FFT(Op): ...@@ -40,22 +43,12 @@ class FFT(Op):
half = False half = False
"""Only return the first half (positive-valued) of the frequency components""" """Only return the first half (positive-valued) of the frequency components"""
__props__ = ("half", "inverse")
def __init__(self, half=False, inverse=False): def __init__(self, half=False, inverse=False):
self.half = half self.half = half
self.inverse = inverse self.inverse = inverse
def __eq__(self, other):
return (type(self) == type(other) and
self.half == other.half and
self.inverse == other.inverse)
def __hash__(self):
return hash(type(self)) ^ hash(self.half) ^ 9828743 ^ (self.inverse)
def __ne__(self, other):
return not(self == other)
def make_node(self, frames, n, axis): def make_node(self, frames, n, axis):
""" compute an n-point fft of frames along given axis """ """ compute an n-point fft of frames along given axis """
_frames = tensor.as_tensor(frames, ndim=2) _frames = tensor.as_tensor(frames, ndim=2)
......
...@@ -14,15 +14,11 @@ if cuda_available: ...@@ -14,15 +14,11 @@ if cuda_available:
class MultinomialFromUniform(Op): class MultinomialFromUniform(Op):
'''Converts samples from a uniform into sample from a multinomial.''' '''Converts samples from a uniform into sample from a multinomial.'''
__props__ = ("odtype",)
def __init__(self, odtype): def __init__(self, odtype):
self.odtype = odtype self.odtype = odtype
def __eq__(self, other):
return type(self) == type(other) and self.odtype == other.odtype
def __hash__(self):
return hash((type(self), self.odtype))
def __str__(self): def __str__(self):
return '%s{%s}' % (self.__class__.__name__, self.odtype) return '%s{%s}' % (self.__class__.__name__, self.odtype)
......
...@@ -16,6 +16,10 @@ from theano import gof, Op ...@@ -16,6 +16,10 @@ from theano import gof, Op
class NeighbourhoodsFromImages(Op): class NeighbourhoodsFromImages(Op):
__props__ = ("n_dims_before", "dims_neighbourhoods", "strides",
"ignore_border", "inverse")
def __init__(self, n_dims_before, dims_neighbourhoods, def __init__(self, n_dims_before, dims_neighbourhoods,
strides=None, ignore_border=False, inverse=False): strides=None, ignore_border=False, inverse=False):
""" """
...@@ -84,20 +88,6 @@ class NeighbourhoodsFromImages(Op): ...@@ -84,20 +88,6 @@ class NeighbourhoodsFromImages(Op):
self.code_string, self.code = self.make_py_code() self.code_string, self.code = self.make_py_code()
def __eq__(self, other):
return type(self) == type(other) and \
self.n_dims_before == other.n_dims_before and \
self.dims_neighbourhoods == other.dims_neighbourhoods and \
self.strides == other.strides and \
self.ignore_border == other.ignore_border
def __hash__(self):
return hash(type(self)) ^ \
hash(self.n_dims_before) ^ \
hash(self.dims_neighbourhoods) ^ \
hash(self.strides) ^ \
hash(self.ignore_border)
def __str__(self): def __str__(self):
return '%s{%s,%s,%s,%s}' % (self.__class__.__name__, return '%s{%s,%s,%s,%s}' % (self.__class__.__name__,
self.n_dims_before, self.n_dims_before,
......
...@@ -78,11 +78,7 @@ class DotModulo(Op): ...@@ -78,11 +78,7 @@ class DotModulo(Op):
We do this 2 times on 2 triple inputs and concatenating the output We do this 2 times on 2 triple inputs and concatenating the output
""" """
def __eq__(self, other): __props__ = ()
return type(self) == type(other)
def __hash__(self):
return hash(type(self))
def make_node(self, A, s, m, A2, s2, m2): def make_node(self, A, s, m, A2, s2, m2):
return Apply(self, [A, s, m, A2, s2, m2], [s.type()]) return Apply(self, [A, s, m, A2, s2, m2], [s.type()])
...@@ -286,6 +282,9 @@ def mrg_next_value(rstate, new_rstate): ...@@ -286,6 +282,9 @@ def mrg_next_value(rstate, new_rstate):
class mrg_uniform_base(Op): class mrg_uniform_base(Op):
__props__ = ("output_type", "inplace")
def __init__(self, output_type, inplace=False): def __init__(self, output_type, inplace=False):
Op.__init__(self) Op.__init__(self)
self.output_type = output_type self.output_type = output_type
...@@ -294,14 +293,6 @@ class mrg_uniform_base(Op): ...@@ -294,14 +293,6 @@ class mrg_uniform_base(Op):
self.destroy_map = {0: [0]} self.destroy_map = {0: [0]}
self.warned_numpy_version = False self.warned_numpy_version = False
def __eq__(self, other):
return (type(self) == type(other) and
self.output_type == other.output_type and
self.inplace == other.inplace)
def __hash__(self):
return hash(type(self)) ^ hash(self.output_type) ^ hash(self.inplace)
def __str__(self): def __str__(self):
if self.inplace: if self.inplace:
s = "inplace" s = "inplace"
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论