提交 49079894 authored 作者: Sina Honari's avatar Sina Honari 提交者: Pascal Lamblin

fixing import pygpu + pval as tensor variable

上级 a124f9cd
......@@ -711,18 +711,32 @@ def test_udefined_grad():
# checking multinomial distribution
prob1 = tensor.scalar()
prob2 = tensor.scalar()
out = srng.multinomial((), pvals=[prob1, 0.5, 0.25], n=4)
assert_raises(theano.gradient.NullTypeGradError, theano.grad, out, prob1)
p = [theano.tensor.as_tensor_variable([prob1, 0.5, 0.25])]
out = srng.multinomial(size=None, pvals=p, n=4)[0]
assert_raises(theano.gradient.NullTypeGradError, theano.grad,
theano.tensor.sum(out), prob1)
out = srng.multinomial((), pvals=[prob1, prob2])
assert_raises(theano.gradient.NullTypeGradError, theano.grad, out,
(prob1, prob2))
p = [theano.tensor.as_tensor_variable([prob1, prob2])]
out = srng.multinomial(size=None, pvals=p, n=4)[0]
assert_raises(theano.gradient.NullTypeGradError, theano.grad,
theano.tensor.sum(out), (prob1, prob2))
# checking choice
out = srng.choice((), p=[[prob1, prob2]], replace=False)
assert_raises(theano.gradient.NullTypeGradError, theano.grad, out,
p = [theano.tensor.as_tensor_variable([prob1, prob2, 0.1, 0.2])]
out = srng.choice(a=None, size=1, p=p, replace=False)[0]
assert_raises(theano.gradient.NullTypeGradError, theano.grad, out[0],
(prob1, prob2))
p = [theano.tensor.as_tensor_variable([prob1, prob2])]
out = srng.choice(a=None, size=1, p=p, replace=False)[0]
assert_raises(theano.gradient.NullTypeGradError, theano.grad, out[0],
(prob1, prob2))
p = [theano.tensor.as_tensor_variable([prob1, 0.2, 0.3])]
out = srng.choice(a=None, size=1, p=p, replace=False)[0]
assert_raises(theano.gradient.NullTypeGradError, theano.grad, out[0],
prob1)
# checking normal distribution
avg = tensor.scalar()
out = srng.normal((), avg=avg)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论