提交 b435dbd6 authored 作者: Nicolas Bouchard's avatar Nicolas Bouchard 提交者: Frederic

Add PoissonTester

上级 c840f595
...@@ -583,7 +583,7 @@ class Multinomial(gof.op.Op): ...@@ -583,7 +583,7 @@ class Multinomial(gof.op.Op):
`p`. `p`.
:param n: Number of experiment. :param n: Number of experiment.
:param p: Sparse matrix ofprobability for each of the different outcomes. :param p: Sparse matrix of probability for each of the different outcomes.
:return: A sparse matrix of random integers of a multinomial density. :return: A sparse matrix of random integers of a multinomial density.
""" """
......
...@@ -250,6 +250,44 @@ class AddSSDataTester(utt.InferShapeTester): ...@@ -250,6 +250,44 @@ class AddSSDataTester(utt.InferShapeTester):
structured=True) structured=True)
class PoissonTester(utt.InferShapeTester):
x = {}
a = {}
for format in sparse.sparse_formats:
variable = getattr(theano.sparse, format + '_matrix')
rand = np.array(np.random.random_integers(3, size=(3, 4)) - 1,
dtype=theano.config.floatX)
x[format] = variable()
a[format] = as_sparse_format(rand, format)
def setUp(self):
super(PoissonTester, self).setUp()
self.op_class = S2.Poisson
def test_op(self):
for format in sparse.sparse_formats:
f = theano.function(
[self.x[format]],
S2.poisson(self.x[format]))
tested = f(self.a[format])
assert tested.format == format
assert tested.dtype == self.a[format].dtype
assert np.allclose(np.floor(tested.data), tested.data)
assert tested.data.shape == self.a[format].data.shape
def test_infer_shape(self):
for format in sparse.sparse_formats:
self._compile_and_check([self.x[format]],
[S2.poisson(self.x[format])],
[self.a[format]],
self.op_class)
class StructuredAddSVTester(unittest.TestCase): class StructuredAddSVTester(unittest.TestCase):
def setUp(self): def setUp(self):
utt.seed_rng() utt.seed_rng()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论