提交 1e81c4d8 authored 作者: David Warde-Farley's avatar David Warde-Farley

matrix_inverse test that triggers LinAlgError.

上级 c9e6bec7
...@@ -77,6 +77,19 @@ def test_inverse_correctness(): ...@@ -77,6 +77,19 @@ def test_inverse_correctness():
assert _allclose(numpy.identity(4), rir), rir assert _allclose(numpy.identity(4), rir), rir
assert _allclose(numpy.identity(4), rri), rri assert _allclose(numpy.identity(4), rri), rri
def test_inverse_singular():
singular = numpy.array([[1, 0, 0]] + [[0, 1, 0]] * 2,
dtype=theano.config.floatX)
a = tensor.matrix()
f = function([a], matrix_inverse(a))
try:
f(singular)
except numpy.linalg.LinAlgError:
return
assert False
def test_inverse_grad(): def test_inverse_grad():
rng = numpy.random.RandomState(utt.fetch_seed()) rng = numpy.random.RandomState(utt.fetch_seed())
r = rng.randn(4, 4) r = rng.randn(4, 4)
...@@ -87,6 +100,7 @@ def test_inverse_grad(): ...@@ -87,6 +100,7 @@ def test_inverse_grad():
r = rng.randn(4,4) r = rng.randn(4,4)
tensor.verify_grad(matrix_inverse, [r], rng=numpy.random) tensor.verify_grad(matrix_inverse, [r], rng=numpy.random)
def test_rop_lop(): def test_rop_lop():
mx = tensor.matrix('mx') mx = tensor.matrix('mx')
mv = tensor.matrix('mv') mv = tensor.matrix('mv')
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论