Skip to content
This repository was archived by the owner on Nov 7, 2024. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions tensornetwork/backends/tensorflow/tensorflow_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,3 +430,18 @@ def eps(self, dtype: Type[np.number]) -> float:
float: Machine epsilon.
"""
return tf.experimental.numpy.finfo(dtype).eps

def pinv(self, tensor: Tensor, rcond: float = 1E-15, hermitian: bool = False) -> Tensor:
"""
Compute the (Moore-Penrose) pseudo-inverse of a tensor.
Returns the pseudo-inverse of tensor.

Args:
tensor: A tensor.
rcond: Cutoff for small singular values.
hermitian(optional): If True, matrix provided is assumed to be Hermitian (symmetric if real-valued). Defaults to False.

Returns:
tensor: The pseudo inverse of tensor.
"""
return np.linalg.pinv(tensor)