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

Merge pull request #3179 from harlouci/props_sparse_sandbox

Props sparse sandbox
......@@ -41,6 +41,7 @@ class ConvolutionIndices(Op):
patch. Convolution is then simply the dot product of (img x M)
and the kernels.
"""
__props__ = ()
@staticmethod
def sparse_eval(inshp, kshp, nkern, strides=(1, 1), mode='valid'):
......
......@@ -61,12 +61,7 @@ class Poisson(gof.op.Op):
:return: A sparse matrix of random integers of a Poisson density
with mean of `x` element wise.
"""
def __eq__(self, other):
return (type(self) == type(other))
def __hash__(self):
return hash(type(self))
__props__ = ()
def make_node(self, x):
x = as_sparse_variable(x)
......@@ -91,8 +86,6 @@ class Poisson(gof.op.Op):
def infer_shape(self, node, ins_shapes):
return ins_shapes
def __str__(self):
return self.__class__.__name__
poisson = Poisson()
......@@ -112,19 +105,12 @@ class Binomial(gof.op.Op):
:return: A sparse matrix of integers representing the number
of success.
"""
__props__ = ("format", "dtype")
def __init__(self, format, dtype):
self.format = format
self.dtype = dtype
def __eq__(self, other):
return ((type(self) == type(other)) and
self.format == other.format and
self.dtype == other.dtype)
def __hash__(self):
return hash(type(self)) ^ hash(self.format) ^ hash(self.dtype)
def make_node(self, n, p, shape):
n = tensor.as_tensor_variable(n)
p = tensor.as_tensor_variable(p)
......@@ -159,9 +145,6 @@ class Binomial(gof.op.Op):
def infer_shape(self, node, ins_shapes):
return [(node.inputs[2][0], node.inputs[2][1])]
def __str__(self):
return self.__class__.__name__
csr_fbinomial = Binomial('csr', 'float32')
csc_fbinomial = Binomial('csc', 'float32')
csr_dbinomial = Binomial('csr', 'float64')
......@@ -189,12 +172,7 @@ class Multinomial(gof.op.Op):
:note: It will works only if `p` have csr format.
"""
def __eq__(self, other):
return (type(self) == type(other))
def __hash__(self):
return hash(type(self))
__props__ = ()
def make_node(self, n, p):
n = tensor.as_tensor_variable(n)
......@@ -238,6 +216,4 @@ class Multinomial(gof.op.Op):
def infer_shape(self, node, ins_shapes):
return [ins_shapes[1]]
def __str__(self):
return self.__class__.__name__
multinomial = Multinomial()
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论