Adds pinv to tensorflow backend (https://github.com/google/TensorNetwork/issues/844)#935
Adds pinv to tensorflow backend (https://github.com/google/TensorNetwork/issues/844)#935krbhanushali wants to merge 3 commits intogoogle:masterfrom
Conversation
mganahl
left a comment
There was a problem hiding this comment.
Thanks for the PR, looks good! Could you also add pinv to the AbstractBackend class, as well as numpy and jax backends?
| np.testing.assert_allclose(expected, actual) | ||
| expected = tf.linalg.pinv(tensor) | ||
| actual = backend.pinv(tensor) | ||
| np.testing.assert_allclose(expected, actual) No newline at end of file |
There was a problem hiding this comment.
add a test that actual @ tensor and tensor @ actual equal the identity (within the desired error)
There was a problem hiding this comment.
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)
| """ | ||
| return tf.experimental.numpy.finfo(dtype).eps | ||
|
|
||
| def pinv(self, tensor: Tensor, rcond: float = 1E-15, hermitian: bool = False) -> Tensor: |
There was a problem hiding this comment.
I think you can remove the hermitian argument
There was a problem hiding this comment.
I had included it as it was an argument for numpy. I'll remove it in the next commit.
Thanks for the review!
Added pinv to tensorflow_backend.py and corresponding tests to tensorflow_backend_tests,py Issue: #844