Add relative threshold while testing inversing #8973
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Inverse of a matrix is a technique which requires extremely delicate care.
Special treatments such as QR factorization are needed when encountering an ill-conditioned matrix.
One simple example:
I understand that QP factorization or Singular Value Decomposition, as well as any other matrix inversion techniques, might be too hard for CS guys, but at least we need to loose the threshold for inversion of matrixes.
The current test
/oneflow/python/oneflow/test/modules/test_inv.py
would fail with a possibility at around 1/6. (Test 6 times and fails 1 of them.)Using
@autotest(n=1000)
would increase the possibility to 100%. (Fails 6/Test 6)Some failed examples:
The second shown example indicates that 1e-3 is not enough, thus we use 1e-2 as the relative threshold.
And absolute threshold is useless when encountering an ill-conditioned matrix.
Therefore, we remove the absolute threshold.