提交 1cda3cfc authored 作者: yobibyte's avatar yobibyte

Fix rebase. Make flake8 silent.

上级 f1f333d0
...@@ -794,6 +794,7 @@ def tensorinv(a, ind=2): ...@@ -794,6 +794,7 @@ def tensorinv(a, ind=2):
""" """
return TensorInv(ind)(a) return TensorInv(ind)(a)
class TensorSolve(Op): class TensorSolve(Op):
""" """
Theano utilization of numpy.linalg.tensorsolve Theano utilization of numpy.linalg.tensorsolve
...@@ -848,5 +849,6 @@ def tensorsolve(a, b, axes=None): ...@@ -848,5 +849,6 @@ def tensorsolve(a, b, axes=None):
------ ------
LinAlgError LinAlgError
If `a` is singular or not 'square' (in the above sense). If `a` is singular or not 'square' (in the above sense).
"""
return TensorSolve(axes)(a, b) return TensorSolve(axes)(a, b)
...@@ -39,7 +39,7 @@ from theano.tensor.nlinalg import ( MatrixInverse, ...@@ -39,7 +39,7 @@ from theano.tensor.nlinalg import ( MatrixInverse,
norm, norm,
svd, svd,
TensorInv, TensorInv,
tensorinv tensorinv,
tensorsolve tensorsolve
) )
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
...@@ -172,9 +172,9 @@ def test_tensorsolve(): ...@@ -172,9 +172,9 @@ def test_tensorsolve():
fn = function([A, B], [X]) fn = function([A, B], [X])
# slightly modified example from numpy.linalg.tensorsolve docstring # slightly modified example from numpy.linalg.tensorsolve docstring
a = numpy.eye(2*3*4).astype(theano.config.floatX) a = numpy.eye(2 * 3 * 4).astype(theano.config.floatX)
a.shape = (2*3, 4, 2, 3*4) a.shape = (2 * 3, 4, 2, 3 * 4)
b = rng.rand(2*3, 4).astype(theano.config.floatX) b = rng.rand(2 * 3, 4).astype(theano.config.floatX)
n_x = numpy.linalg.tensorsolve(a, b) n_x = numpy.linalg.tensorsolve(a, b)
t_x = fn(a, b) t_x = fn(a, b)
...@@ -186,9 +186,9 @@ def test_tensorsolve(): ...@@ -186,9 +186,9 @@ def test_tensorsolve():
Y = tensorsolve(C, D) Y = tensorsolve(C, D)
fn = function([C, D], [Y]) fn = function([C, D], [Y])
c = numpy.eye(2*3*4).astype('float32') c = numpy.eye(2 * 3 * 4, dtype='float32')
c.shape = (2*3, 4, 2, 3*4) c.shape = (2 * 3, 4, 2, 3 * 4)
d = rng.rand(2*3, 4).astype('float64') d = rng.rand(2 * 3, 4).astype('float64')
n_y = numpy.linalg.tensorsolve(c, d) n_y = numpy.linalg.tensorsolve(c, d)
t_y = fn(c, d) t_y = fn(c, d)
assert _allclose(n_y, t_y) assert _allclose(n_y, t_y)
...@@ -200,9 +200,9 @@ def test_tensorsolve(): ...@@ -200,9 +200,9 @@ def test_tensorsolve():
Z = tensorsolve(E, F) Z = tensorsolve(E, F)
fn = function([E, F], [Z]) fn = function([E, F], [Z])
e = numpy.eye(2*3*4).astype('int32') e = numpy.eye(2 * 3 * 4, dtype='int32')
e.shape = (2*3, 4, 2, 3*4) e.shape = (2 * 3, 4, 2, 3 * 4)
f = rng.rand(2*3, 4).astype('float64') f = rng.rand(2 * 3, 4).astype('float64')
n_z = numpy.linalg.tensorsolve(e, f) n_z = numpy.linalg.tensorsolve(e, f)
t_z = fn(e, f) t_z = fn(e, f)
assert _allclose(n_z, t_z) assert _allclose(n_z, t_z)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论