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