提交 ffa88a6b authored 作者: Brandon T. Willard's avatar Brandon T. Willard 提交者: Brandon T. Willard

Rename aesara.tensor.nlinalg.lstsq class to Lstsq and create Op instance

上级 86282bdd
...@@ -591,7 +591,7 @@ def svd(a, full_matrices=1, compute_uv=1): ...@@ -591,7 +591,7 @@ def svd(a, full_matrices=1, compute_uv=1):
return SVD(full_matrices, compute_uv)(a) return SVD(full_matrices, compute_uv)(a)
class lstsq(Op): class Lstsq(Op):
__props__ = () __props__ = ()
...@@ -618,6 +618,9 @@ class lstsq(Op): ...@@ -618,6 +618,9 @@ class lstsq(Op):
outputs[3][0] = zz[3] outputs[3][0] = zz[3]
lstsq = Lstsq()
def matrix_power(M, n): def matrix_power(M, n):
r"""Raise a square matrix, ``M``, to the (integer) power ``n``. r"""Raise a square matrix, ``M``, to the (integer) power ``n``.
......
...@@ -16,6 +16,7 @@ from aesara.tensor.nlinalg import ( ...@@ -16,6 +16,7 @@ from aesara.tensor.nlinalg import (
det, det,
eig, eig,
eigh, eigh,
lstsq,
matrix_dot, matrix_dot,
matrix_inverse, matrix_inverse,
matrix_power, matrix_power,
...@@ -372,7 +373,7 @@ class TestLstsq: ...@@ -372,7 +373,7 @@ class TestLstsq:
x = lmatrix() x = lmatrix()
y = lmatrix() y = lmatrix()
z = lscalar() z = lscalar()
b = aesara.tensor.nlinalg.lstsq()(x, y, z) b = lstsq(x, y, z)
f = function([x, y, z], b) f = function([x, y, z], b)
TestMatrix1 = np.asarray([[2, 1], [3, 4]]) TestMatrix1 = np.asarray([[2, 1], [3, 4]])
TestMatrix2 = np.asarray([[17, 20], [43, 50]]) TestMatrix2 = np.asarray([[17, 20], [43, 50]])
...@@ -385,7 +386,7 @@ class TestLstsq: ...@@ -385,7 +386,7 @@ class TestLstsq:
x = vector() x = vector()
y = vector() y = vector()
z = scalar() z = scalar()
b = aesara.tensor.nlinalg.lstsq()(x, y, z) b = lstsq(x, y, z)
f = function([x, y, z], b) f = function([x, y, z], b)
with pytest.raises(np.linalg.linalg.LinAlgError): with pytest.raises(np.linalg.linalg.LinAlgError):
f([2, 1], [2, 1], 1) f([2, 1], [2, 1], 1)
...@@ -394,7 +395,7 @@ class TestLstsq: ...@@ -394,7 +395,7 @@ class TestLstsq:
x = vector() x = vector()
y = vector() y = vector()
z = vector() z = vector()
b = aesara.tensor.nlinalg.lstsq()(x, y, z) b = lstsq(x, y, z)
f = function([x, y, z], b) f = function([x, y, z], b)
with pytest.raises(np.linalg.LinAlgError): with pytest.raises(np.linalg.LinAlgError):
f([2, 1], [2, 1], [2, 1]) f([2, 1], [2, 1], [2, 1])
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论