Example #1
0
    def test_op(self):
        n = tensor.lscalar()
        f = theano.function([self.p, n], multinomial(n, self.p))

        _n = 5
        tested = f(self._p, _n)
        assert tested.shape == self._p.shape
        assert numpy.allclose(numpy.floor(tested.todense()), tested.todense())
        assert tested[2, 1] == _n

        n = tensor.lvector()
        f = theano.function([self.p, n], multinomial(n, self.p))

        _n = numpy.asarray([1, 2, 3, 4], dtype='int64')
        tested = f(self._p, _n)
        assert tested.shape == self._p.shape
        assert numpy.allclose(numpy.floor(tested.todense()), tested.todense())
        assert tested[2, 1] == _n[2]
Example #2
0
    def test_op(self):
        n = tensor.lscalar()
        f = theano.function([self.p, n], multinomial(n, self.p))

        _n = 5
        tested = f(self._p, _n)
        assert tested.shape == self._p.shape
        assert np.allclose(np.floor(tested.todense()), tested.todense())
        assert tested[2, 1] == _n

        n = tensor.lvector()
        f = theano.function([self.p, n], multinomial(n, self.p))

        _n = np.asarray([1, 2, 3, 4], dtype='int64')
        tested = f(self._p, _n)
        assert tested.shape == self._p.shape
        assert np.allclose(np.floor(tested.todense()), tested.todense())
        assert tested[2, 1] == _n[2]
Example #3
0
 def test_infer_shape(self):
     self._compile_and_check([self.p],
                             [multinomial(5, self.p)],
                             [self._p],
                             self.op_class,
                             warn=False)
Example #4
0
 def test_infer_shape(self):
     self._compile_and_check([self.p], [multinomial(5, self.p)], [self._p],
                             self.op_class,
                             warn=False)