-
Notifications
You must be signed in to change notification settings - Fork 356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds pinv to tensorflow backend (https://github.com/google/TensorNetwork/issues/844) #935
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -629,3 +629,15 @@ def test_power(dtype): | |
def test_eps(dtype): | ||
backend = tensorflow_backend.TensorFlowBackend() | ||
assert backend.eps(dtype) == tf.experimental.numpy.finfo(dtype).eps | ||
|
||
def test_pinv(): | ||
backend = tensorflow_backend.TensorFlowBackend() | ||
np.random.seed(10) | ||
tensor = np.random.rand(2, 3, 4) | ||
rcond = np.random.rand(1)[0] * 1E-14 | ||
expected = tf.linalg.pinv(tensor, rcond) | ||
actual = backend.pinv(tensor, rcond) | ||
np.testing.assert_allclose(expected, actual) | ||
expected = tf.linalg.pinv(tensor) | ||
actual = backend.pinv(tensor) | ||
np.testing.assert_allclose(expected, actual) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add a test that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would testing for all the criteria in https://en.wikipedia.org/wiki/Moore%E2%80%93Penrose_inverse be a better test? (As for an example given in tf's documentation, the product wasn't identity) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can remove the
hermitian
argumentThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had included it as it was an argument for numpy. I'll remove it in the next commit.
Thanks for the review!